Abstract
Within a large database $\mathcal{G}$ containing graphs with labeled nodes and directed, multi-edges; how can we detect the anomalous graphs? Most existing work are designed for plain (unlabeled) and/or simple (unweighted) graphs. We introduce CODETECT, the first approach that addresses the anomaly detection task for graph databases with such complex nature. To this end, it identifies a small representative set $S$ of structural patterns (i.e., node-labeled network motifs) that losslessly compress database $\mathcal{G}$ as concisely as possible. Graphs that do not compress well are flagged as anomalous. CODETECT exhibits two novel building blocks: (i) a motif-based lossless graph encoding scheme, and (ii) fast memory-efficient search algorithms for $S$. We show the effectiveness of CODETECT on transaction graph databases from three different corporations, where existing baselines adjusted for the task fall behind significantly, across different types of anomalies and performance metrics.
Introduction: The Challenge of Complex Graph Databases
Most graph anomaly detection research focuses on identifying unusual nodes or edges within a single large graph. However, many critical real-world applications—such as corporate accounting, software debugging, or email monitoring—generate databases where each entry is an individual, complex graph.
In accounting, for instance, a "journal entry" is a graph where nodes represent accounts and edges represent transactions. These graphs are inherently complex: they feature node labels (e.g., "Revenue" vs. "Asset"), directed edges, and "multi-edges" (multiple distinct transactions between the same two accounts). Existing tools often fail to handle this complexity, typically ignoring labels or struggling with the volume of multi-edges. As shown in the comparison below, CODETECT is the first method to simultaneously address graph databases, node labels, multi/weighted edges, and directed edges for anomaly detection.
Methodology: Compression as Detection
The authors propose CODEtect, a framework based on the Minimum Description Length (MDL) principle. MDL posits that the best model for a dataset is the one that provides the most concise description. In this context, anomalies are patterns that deviate from the "global theory" of the data and are thus harder to compress.
1. Lossless Graph Encoding
CODEtect constructs a "motif table"—a dictionary of common structural patterns (motifs) found across the database. It then attempts to describe every graph in the database using these motifs. A graph that can be represented by a few common motifs results in a short "code length." Conversely, graphs requiring many unique or rare descriptions yield long code lengths, which serve as their anomaly scores.
2. Efficient Search Algorithms
Identifying the optimal set of motifs is a computationally intensive search problem. CODETECT employs a greedy approach based on the Maximum Independent Set (MIS) problem to find non-overlapping motif occurrences. To manage the memory explosion inherent in multi-edges, the authors developed a "memory-efficient" search variant. By operating on "simple occurrences" rather than enumerating every possible edge combination, they reduced memory requirements by up to nine orders of magnitude, enabling linear scaling with the number of edges.
Experimental Evaluation
CODEtect was evaluated on several diverse datasets, including proprietary accounting data from three corporations (SH, HW, KD), a synthetic version of the SH data for reproducibility, and the public Enron email database.
Key Results
- Superior Accuracy: On the SH dataset, CODETECT achieved a Precision@10 of 1.000 and an AUC of 0.958, significantly outperforming the next best baseline (SMT at 0.932 AUC). On average, it provided a 10% to 17% improvement over runner-up methods.
- Scalability: The system demonstrates linear scaling in both time and memory usage relative to the number of multi-edges, making it viable for massive production databases.
- Qualitative Validation: In a case study using the Enron dataset, the highest anomaly scores aligned precisely with major milestones of the Enron scandal, such as the CEO transition and the commencement of the DOJ investigation.
Conclusion
CODEtect addresses a critical gap in graph mining by providing a robust, scalable solution for anomaly detection in complex graph databases. By leveraging lossless compression via motifs, it captures subtle structural deviations that traditional embedding methods often overlook. Future work may explore relaxing the non-overlapping constraint for motifs and integrating temporal dynamics to track how "normal" patterns evolve over time.
Summary updated