graphgen
**GraphGen** is an autoregressive graph generation model that represents graphs as sequences of canonical orderings and uses deep recurrent networks to learn the distribution over graph structures, generating novel graphs one edge at a time following a minimum DFS (depth-first search) code ordering. GraphGen improves upon GraphRNN by using a more compact and canonical graph representation that reduces the sequence length and eliminates ordering ambiguity.
**Why GraphGen Matters in AI/ML:**
GraphGen addresses the **graph ordering ambiguity problem** in autoregressive graph generation—since a graph of N nodes has N! possible orderings—by using canonical minimum DFS codes that provide a unique, compact representation, enabling more efficient and accurate generative modeling.
• **Minimum DFS code** — Each graph is represented by its minimum DFS code: the lexicographically smallest sequence obtained by performing DFS traversals from all possible starting nodes; this provides a canonical (unique) ordering that eliminates the N! ordering ambiguity
• **Edge-level autoregression** — GraphGen generates graphs edge by edge (rather than node by node like GraphRNN), where each step adds an edge defined by (source_node, target_node, edge_label); this is more granular than node-level generation and captures edge-level dependencies
• **LSTM-based generator** — A multi-layer LSTM processes the sequence of DFS code edges and predicts the next edge at each step; the model learns P(e_t | e_1, ..., e_{t-1}) using teacher forcing during training and autoregressive sampling during generation
• **Compact representation** — The minimum DFS code is significantly shorter than the adjacency matrix flattening used by other methods: for a graph with N nodes and E edges, the DFS code has O(E) entries versus O(N²) for full adjacency matrices
• **Graph validity** — By construction, the DFS code ordering ensures that generated sequences always correspond to valid, connected graphs; invalid edge additions are prevented by the generation grammar, eliminating the need for post-hoc validity filtering
| Property | GraphGen | GraphRNN | GraphVAE |
|----------|----------|----------|----------|
| Ordering | Min DFS code (canonical) | BFS ordering | No ordering (one-shot) |
| Generation Unit | Edge | Node + edges | Full graph |
| Sequence Length | O(E) | O(N²) | 1 (full adjacency) |
| Ordering Ambiguity | None (canonical) | Partial (BFS) | None (permutation-invariant) |
| Architecture | LSTM | GRU (hierarchical) | VAE |
| Connectivity | Guaranteed (DFS tree) | Not guaranteed | Not guaranteed |
**GraphGen advances autoregressive graph generation through minimum DFS code representations that provide canonical, compact graph orderings, enabling edge-level generation with guaranteed connectivity and eliminating the ordering ambiguity that limits other sequential graph generation methods.**