Abstract
Temporal motifs are recurring subgraphs in time-stamped networks that reveal fundamental structural and dynamic properties. However, counting these motifs in massive graphs is computationally prohibitive due to the combinatorial explosion of potential matches. We present TEACUPS (Temporal Explorations Accurately Counted Using Path Sampling), a novel randomized algorithm that utilizes temporal path sampling to estimate motif counts. TEACUPS achieves up to a 2000x speedup over state-of-the-art GPU-based exact counting methods while maintaining high accuracy (relative error < 10%). Our approach enables the analysis of complex 4-vertex patterns on datasets with hundreds of millions of edges, such as Bitcoin and Reddit transaction logs.
Introduction
In network science, motifs serve as building blocks of complex systems. While static motif analysis is well-established, most modern datasets—ranging from financial transactions to social media interactions—are temporal. In these graphs, edges are associated with timestamps, and the validity of a motif match depends not only on the topology but also on the chronological order and temporal proximity of interactions.
The primary challenge in temporal motif counting is the sheer volume of matches. A graph with millions of nodes can contain trillions of temporal motif instances. Furthermore, real-world data often manifests as multi-graphs, where pairs of nodes interact repeatedly. Existing exact counting algorithms, even those leveraging high-performance GPUs, often require days to process such data, limiting analysis to small graphs or simple patterns.
Methods: Temporal Path Sampling
TEACUPS addresses the scalability bottleneck by shifting from exact enumeration to unbiased estimation via sampling. The core of the algorithm is a specialized temporal 3-path sampling technique.
$\delta$-Centered 3-Paths
Every connected 4-vertex motif contains at least one 3-path. TEACUPS defines a "$\delta$-centered 3-path" as a sequence of three edges where the two outer edges occur within a maximum time window $\delta$ of the center edge. By sampling these paths as "anchors," the algorithm avoids exploring the entire search space.
Algorithm Workflow
- Preprocessing: The algorithm calculates sampling weights for every edge, representing the number of $\delta$-centered 3-paths that use that edge as a center. This is performed efficiently using binary search on time-sorted adjacency lists.
- Sampling Loop: 3-paths are sampled uniformly based on these weights. A
CHECKMOTIFprocedure then determines how many ways a sampled path can be extended into the full target motif. - Multi-graph Optimization: To handle the high frequency of multi-graph motifs, TEACUPS uses a dynamic programming-style approach (
LISTCOUNT) to count valid edge combinations in linear time relative to the number of edges between node pairs, rather than enumerating them individually.
Experimental Evaluation
The performance of TEACUPS was evaluated on four large-scale temporal datasets: wiki-talk (WT), stackoverflow (SO), bitcoin (BI), and reddit-reply (RE). These datasets range from 7.8M to 636.3M edges, representing a significant scale-up from previous benchmarks.
Runtime Performance
TEACUPS demonstrates massive speedups compared to prior work. On average, it is 30x faster than Everest, a state-of-the-art GPU-based exact counter. In extreme cases, the speedup reaches 2000x. For instance, on the Bitcoin graph (113M edges), TEACUPS completes in under one minute on a standard CPU, whereas exact counting on an NVIDIA A40 GPU exceeds 24 hours.
Accuracy and Scalability
Despite being a sampling-based approach, TEACUPS maintains high precision. Across all tested motifs and datasets, the relative error remained consistently below 10%. The algorithm is mathematically unbiased, and the authors provide theoretical concentration bounds to guarantee estimate reliability. Additionally, TEACUPS exhibits near-linear scalability with the number of CPU threads, making it highly efficient for modern multi-core systems.
Conclusion
TEACUPS represents a significant advancement in temporal network analysis. By combining edge-centric path sampling with efficient multi-graph handling, it makes the study of complex 4-vertex temporal motifs practical for massive, real-world datasets. Future work includes automating the selection of optimal "anchor" paths to further reduce variance and extending the methodology to larger motifs or non-connected patterns.
Summary updated