---
title: 'Mayura: Temporal Co-Mining for Motif Analysis'
url: https://www.emergentmind.com/topics/mayura
type: topic
---

# Mayura: Temporal Co-Mining for Motif Analysis

Searching arXiv for the specified paper to ground the article and citation.
Mayura is a system for exact, high-performance co-mining of multiple temporal motifs in large temporal graphs. It is introduced in "Mayura: Exploiting Similarities in Motifs for Temporal Co-Mining" [2507.14813] and targets workloads in which several related motifs must be mined at once, a setting that arises in fraud detection, cybersecurity, and dynamic network analysis. Its central premise is that independently mining each query motif wastes work when motifs share structural edge prefixes and temporal orderings. Mayura addresses that redundancy by organizing motifs into a Motif-Group Tree (MG-Tree), reusing partial matches across related motifs, and providing CPU and GPU runtimes that preserve exactness while reducing repeated candidate exploration [2507.14813].

## 1. Problem setting and conceptual basis

Temporal graphs encode time-stamped interactions between entities. In the formalism used by Mayura, a temporal graph is a directed, time-stamped edge set over a vertex set, and temporal motifs are small, time-ordered patterns whose counts or enumerations serve as signals in anti-money laundering (AML), fraud rings, phishing cascades, insider-threat sequences, social interaction dynamics, and power grid events [2507.14813]. The motivating inefficiency is that conventional motif mining approaches treat each query independently, even when multiple motifs share early temporal and structural subpatterns.

The canonical example in the paper is that a 3-cycle and a 4-cycle may share their first two time-ordered edges. If they are mined separately, the graph is re-traversed along the same paths multiple times. Mayura co-mines them once along the shared prefix and then branches. This design makes Mayura a multi-query exact temporal motif miner rather than a single-query optimization. The paper’s stated objective is not approximation, sketching, or relaxed matching, but exact counting and enumeration with strict isomorphism semantics [2507.14813].

A useful distinction in the paper is between common prefixes and motif-specific suffixes. Common prefixes are mined once, while divergence points induce branching in the search. This shifts the computational unit from an isolated motif to a hierarchy of related motifs. A plausible implication is that Mayura is most effective when query design itself reflects domain families of patterns rather than unrelated one-off motifs; the paper formalizes this dependence through its Similarity Metric and confirms it empirically [2507.14813].

## 2. Formal model of temporal motifs and counting

Mayura defines a temporal graph as

$$
G = (V_G, E_G),
$$

where $V_G$ is a set of vertices and $E_G$ is an ordered list of $n$ temporal edges,

$$
E_G = \{(u_i, v_i, t_i)\}_{i=1}^n,
$$

with $u_i, v_i \in V_G$ and $t_i \in \mathbb{R}^+$. Edges are chronologically ordered with unique timestamps, and vertices and edges may carry attributes [2507.14813].

A $\delta$-temporal motif is an ordered sequence of $m$ edges with relative time order and window,

$$
M = (V_M, E_M), \qquad E_M = \{(u_i, v_i, t_i)\}_{i=1}^m,
$$

with $u_i, v_i \in V_M$. A motif instance in $G$ must satisfy strict temporal order and a time window:

$$
t_1 < t_2 < \ldots < t_m, \qquad t_m - t_1 \le \delta.
$$

Matches are strict subgraph isomorphisms between motif vertices and data graph vertices, using a bijective mapping that adheres to the motif’s edge directions and time constraints [2507.14813].

The exact counting objective is

$$
C_M(G, \delta) = |\{\text{matches of } M \text{ in } G \text{ with } t_1 < \ldots < t_m \text{ and } t_m - t_1 \le \delta\}|.
$$

Mayura supports both counting and enumeration, although the paper focuses primarily on counting. The baseline exact miner, following Mackey et al., uses chronological edge-driven backtracking with an `e_stack` of matched edges in increasing timestamp order, bijective mappings `m2g` and `g2m` between motif and graph vertices, and `incnt`, an incident count per graph vertex over currently matched edges. It selects candidates for each motif edge, prunes by temporal constraints, enforces structural constraints, and recurses until all motif edges are matched, then increments the count $C_M$ [2507.14813].

This baseline is exact but query-isolated. Mayura preserves the same temporal and structural semantics while replacing repeated per-motif search with shared search over a motif hierarchy.

## 3. MG-Tree: hierarchical organization of shared temporal prefixes

The MG-Tree is the core data structure through which Mayura exploits commonality among motifs. Let $MG = \{M_1, \ldots, M_k\}$ be a set of $\delta$-temporal motifs. The MG-Tree, denoted $MGT$, is a rooted tree whose nodes are triples

$$
N = \langle C_N, Children(N), Q_N \rangle,
$$

where $C_N$ is a motif prefix common to all descendants, $Children(N)$ is the set of immediate descendants formed by extending that prefix, and $Q_N$ is either $\emptyset$ or a reference to some query motif $M_i \in MG$ when $C_N \equiv M_i$ [2507.14813].

The paper imposes three defining properties. First, for any descendant $N_{\text{desc}}$, the first $|E(C_N)|$ edges equal $C_N$, so the node stores a true common prefix. Second, $C_N$ is the longest proper prefix of each child’s common motif. Third, every query motif appears exactly once as some nonempty $Q_N$, and the root node has $C_{N_{\text{root}}}$ equal to the longest common prefix shared by all motifs in $MG$ [2507.14813].

Construction proceeds by first building, for each motif $M$, a `TMap` from motif timestamps to edges. A leaf node is inserted for each motif with $C_N \leftarrow M$, $Q_N \leftarrow M$, and empty children. A root node with empty prefix and empty query reference is then created. The recursive `CreateTree` procedure partitions the current motif group by their edge at timestamp $T$ using `TMap`; if some motif in the subgroup has $|E(M)| = T$, then the parent’s common motif equals a query motif and `Q_parent` is set accordingly. If the subgroup does not split, the parent is reused; otherwise an intermediate node is created with prefix edges $[1:T]$, inserted under the parent, and recursion continues on timestamp $T+1$ [2507.14813].

The principal significance of the MG-Tree is that it identifies “common search paths.” For a shared prefix, mining $C_N$ explores `e_stack` once and amortizes that work over all children. It also exposes hierarchical parallelism, because sibling subtrees can be mined independently once the common prefix has been matched [2507.14813].

The illustrative example in the paper considers three motifs whose first two edges are identical: $t_1: A \to B$ and $t_2: B \to C$. One child leaf corresponds to a 3-cycle with third edge $C \to A$; another child is an intermediate node for an extended path, with leaf children depending on the fourth edge. Matching the prefix once allows Mayura to branch without revisiting the same partial matches.

## 4. Co-mining algorithm and exactness guarantees

Mayura’s co-mining algorithm replaces a single-motif recursive miner with traversal guided by the MG-Tree. The main routine `TemporalCoMining(G, N_root, δ)` invokes `CoMatchEdge(G, N_root, δ, e_idx=0)`. For a node $N$, the algorithm lets $M \leftarrow C_N$, the common motif at that node. If `e_idx = |E(M)|`, then the common prefix has been fully matched; if $Q_N \neq \emptyset$, the count for that motif is incremented and the current `e_stack` may be recorded for enumeration. The algorithm then recursively mines each child node using the current `e_stack` as a partial match [2507.14813].

If the current prefix is not yet fully matched, the algorithm selects candidates for the next motif edge. When the motif source vertex is already mapped in `m2g`, candidates are restricted to its out-edges in the adjacency list; otherwise all graph edges may be considered. Each candidate is filtered by temporal constraints: if `e_idx > 0` and the candidate timestamp is earlier than the previous matched edge, it is rejected; if `e_idx > 0` and the candidate would violate the $\delta$ window relative to the first matched edge, it is also rejected. Structural constraints then enforce consistency of the current bijection. Valid candidates are pushed onto `e_stack`, the mappings and incidence counts are updated via `RollOnEdge`, recursion proceeds to `e_idx + 1`, and then the context is restored via `RollBackEdge` [2507.14813].

The paper’s exactness argument has four parts. First, strict isomorphism is maintained because `m2g` and `g2m` enforce bijective correspondence throughout exploration, while `incnt` identifies when a mapping can be released during backtracking. Second, temporal validity is maintained because the algorithm enforces $t(e_i) < t(e_{i+1})$ and $t(e_{\text{last}}) - t(e_{\text{first}}) \le \delta$ at every extension. Third, each motif $M_i$ is counted only at the unique node where $Q_N = M_i$, eliminating duplicate counts from shared prefixes. Fourth, in parallel GPU execution, sibling exploration is restricted or partitioned so that any specific search path is explored by exactly one thread [2507.14813].

The paper therefore states that Mayura’s counts equal $C_M(G, \delta)$ for each motif in the motif group. This directly addresses a common misconception about shared-search systems: Mayura is not a heuristic coalescing of approximate searches, but an exact multi-query miner with no double-counting under its stated assumptions.

## 5. Similarity metric, cost model, and computational behavior

Mayura’s cost model begins from the observation that independent mining cost scales with the number of candidate combinations explored per motif; with $\ell$ motif edges, this is roughly the product of candidate counts per level after pruning. Co-mining changes this scaling by amortizing work spent on a shared prefix $C_N$ across all descendants. If a prefix is shared by $s$ motifs and exploring that prefix costs $W_{\text{prefix}}$, then Mayura pays $W_{\text{prefix}}$ once instead of $s \cdot W_{\text{prefix}}$ [2507.14813].

To quantify reuse potential, the paper proposes the Similarity Metric (SM):

$$
SM(MG, MGT) = 1 - \frac{\sum_{M \in MG\text{-}Tree} (||E_M|| - ||E_{M.parent}||)}{\sum_{M \in MG} ||E_M||},
$$

where $||E_M||$ is the number of edges in motif $M$. Higher SM implies greater commonality and more reuse opportunities. The empirical results reported in the paper state that observed speedups follow SM trends, while also being modulated by hardware utilization and load balance [2507.14813].

The paper’s toy example makes the savings explicit. For co-mining $M3: A \to B \to C \to A$, $M4: A \to B \to C \to D$, and $M5: A \to B \to C \to E$, suppose the number of candidate $A \to B$ edges is $R$, and for each, the number of valid $B \to C$ edges after temporal pruning is $S$. Independent mining evaluates the prefix $A \to B \to C$ three times, costing approximately $3 \cdot (R \cdot S)$ candidate checks before branching. Mayura mines the shared prefix once at cost $R \cdot S$ and then branches, yielding approximately $R \cdot S + (T_3 + T_4 + T_5)$ instead of $3 \cdot R \cdot S + (T_3 + T_4 + T_5)$, for a savings of approximately $2 \cdot R \cdot S$ candidate checks [2507.14813].

This suggests that the principal determinant of Mayura’s benefit is not merely motif count, but overlap structure: many motifs with little shared prefix are less favorable than fewer motifs with deep common temporal prefixes.

## 6. Runtime architecture on CPU and GPU

Mayura’s workflow consists of compile-time preprocessing and runtime execution. At compile time, the system builds CSR-like adjacency with edges sorted by time, constructs the MG-Tree, generates backend-specific code specialized to that tree, and compiles the result. At runtime, it loads the graph into host or GPU memory, schedules work across threads or warps, maintains thread-local context such as `e_stack`, mappings, and counters, and aggregates counts [2507.14813].

The CPU backend distributes candidates for the first edge across threads and uses dynamic task scheduling to balance load. Its code generation unrolls recursive calls into nested loops tailored to MG-Tree levels. The paper reports that this produces predictable control flow, improves branch predictor accuracy, and reduces overhead [2507.14813].

The GPU backend uses two-level load balancing. Intra-warp balancing periodically polls idle threads and redistributes candidate ranges using warp-level primitives; only one source thread explores siblings to avoid duplicate counts, except under sibling-splitting. Inter-warp balancing periodically detects idle warps using global memory flags, serializes thread contexts—partial match stacks and candidate lists—to global memory, repartitions candidate ranges across warps, restores contexts, and resumes mining [2507.14813].

The paper identifies four GPU-specific optimizations. Register-bound context mapping replaces flexible array-based mapping with fixed registers such as $V0 \ldots Vk$ derived from MG-Tree motif sizes, eliminating memory accesses and reducing latency. Predicated execution compiles structural checks into predicated arithmetic and logic operations to avoid branch divergence. Expression simplification fuses logical operations into LUT instructions, reducing instruction count and register pressure. Finally, sibling-splitting and multi-offload increase parallelism across the hierarchy: sibling-splitting assigns sibling node exploration to a nominated idle thread within a warp, while multi-offload decomposes serialized contexts across multiple hierarchy levels so that resuming work distributes MG-Tree nodes across warps [2507.14813].

The architectural trade-off is explicit in the paper. Co-mining reduces instruction counts but can reduce occupancy because more per-thread state is required. The GPU optimizations are therefore not incidental; they are mechanisms for recovering performance that would otherwise be lost to warp divergence, register pressure, and uneven search-tree workloads.

## 7. Empirical evaluation, applications, and limitations

The evaluation uses five real-world datasets and compares Mayura with Mackey et al.’s chronological edge-driven exact miner on CPU and Everest on GPU [2507.14813].

| Dataset | Scale | Temporal setting |
|---|---|---|
| wiki-talk (wtt) | 1.14M vertices, 7.83M temporal edges | $\delta = 1$ day, time span 6.24 years |
| stackoverflow (sxo) | 2.60M vertices, 63.50M edges | $\delta = 1$ day, span 7.6 years |
| reddit-reply (trr) | 8.90M vertices, 646.04M edges | $\delta = 10$ hours, span 10.1 years |
| ethereum (eth) | 66.32M vertices, 628.81M edges | $\delta = 1$ hour, span 3.58 years |
| equinix (eqx) | 6.21M vertices, 872.12M edges | $\delta = 3.6$ms, span 23.46 minutes; subsampled to fit GPU memory (37.5% edges) |

The query workload contains fourteen motifs grouped into eight queries with MG-Trees emphasizing depth-focused groups $(D1, D2)$, fanout-focused groups $(F1\text{–}F3)$, and heterogeneous groups $(C1\text{–}C3)$. Across datasets and motif groups, the paper reports an overall average speed-up of approximately $2.4\times$ on CPU and approximately $1.7\times$ on GPU, with maximum speedups up to approximately $8.8\times$ on CPU and approximately $7.6\times$ on GPU [2507.14813].

The reported microarchitectural effects are equally central. Mayura yields $1.6\text{–}4.5\times$ fewer dynamic instructions due to shared prefix pruning and code generation, and the GPU predication and LUT fusion alleviate $87\text{–}94\%$ of divergence penalties. On CPU, the paper attributes speedups to fewer instructions and improved branch throughput. On GPU, the paper notes that co-mining can reduce occupancy because per-thread state increases, but that active threads per warp and workload balance improve after the proposed optimizations [2507.14813].

The dataset-dependent behavior is also explicit. The eqx bipartite traffic dataset shows exceptional speedups because many motifs are impossible when edges within the same partition are disallowed, allowing shared prefix pruning to eliminate entire subtrees. By contrast, eth and trr have higher motif match density $\sigma = |matches| / |E_G|$; threads spend longer on each node, which limits sibling exploration concurrency and reduces co-mining benefit. Smaller windows $(\delta/2)$ yield larger speedups than larger windows $(2\delta)$ because temporal pruning is more effective and trees are narrower; the GPU backend’s finer-grained load balancing reduces this sensitivity relative to CPU [2507.14813].

The applications emphasized in the paper include AML and fraud detection, where common prefixes such as $A \to B \to C$ occur across multiple rapid-transaction schemes; cybersecurity, where login sequences, privilege escalation patterns, and beaconing cascades share initial temporal edges; social and diffusion analysis, where triadic closures and directed reciprocations share early interactions; and energy disaggregation, where repeated device activation sequences share early event edges [2507.14813].

The limitations are equally well-defined. Benefits depend on inter-motif similarity, and low-SM groups such as C1 may see limited gains. GPU performance can even degrade modestly when overlaps are small because register footprint and warp divergence increase. Larger $\delta$ widens search trees and dilutes pruning and reuse. High match density $\sigma$ serializes exploration at nodes, limiting sibling parallelism. The graph model assumes directed edges with unique timestamps and strict isomorphism with chronological order; Mayura does not target homomorphism or snapshot-based definitions. Resource pressure is nontrivial on GPU: the paper reports that increasing per-thread registers from 44 to 67 reduces active blocks by approximately $31\%$ when co-mining many motifs, while context serialization for inter-warp balancing uses approximately $0.1\text{–}2.5\%$ of dataset-sized global memory [2507.14813].

For reproducibility, the implementation uses MG-Tree construction, CSR-like adjacency lists sorted by timestamps, C++ with OpenMP for CPU, CUDA C for GPU, backend-specific code generation tailored to the MG-Tree, and periodic intra- and inter-warp balancing with interval parameters `INTRA_INTERVAL` and `INTER_INTERVAL`. The datasets are drawn from SNAP, Reddit reply, Ethereum via Zenodo, and Equinix traffic. The paper reports exactness, algorithms, and parameters, but does not include a public code release link. This suggests that reproduction is facilitated by standard graph representations and publicly available datasets, but not by an already packaged reference implementation [2507.14813].

Source: https://www.emergentmind.com/topics/mayura