NetGAN: Generating Graphs via Random Walks

Aleksandar Bojchevski, Oleksandr Shchur, Daniel Zügner, Stephan Günnemann

TL;DR

NetGAN is an implicit generative model for graphs that mimics real-world network topology by learning the distribution of biased random walks. By combining a Generative Adversarial Network (GAN) architecture with LSTM-based sequence generation, it produces synthetic graphs that preserve complex structural properties—like community clusters and degree distributions—and generalizes remarkably well to link prediction tasks.

The Challenge of Graph Generation

Generating realistic graphs is notoriously difficult. Traditional "prescribed" models, like the Barabási-Albert model, rely on fixed mathematical rules that often fail to capture the messy, multi-faceted characteristics of real-world networks, such as heavy-tailed degree distributions or specific clustering patterns.

On the deep learning side, GANs have revolutionized image generation but struggle with graphs for three main reasons:

  1. Discreteness: Graphs consist of discrete nodes and edges, making gradient-based optimization (which requires continuity) difficult.
  2. Permutation Invariance: A graph is the same regardless of how you order its nodes, but standard neural networks are sensitive to input ordering.
  3. Data Scarcity: Unlike image datasets with millions of samples, we often only have one large graph to learn from.

Methods: Learning from Random Walks

To overcome these hurdles, the authors propose a shift in perspective: instead of trying to generate a massive adjacency matrix all at once, NetGAN learns to generate random walks that look like they came from the original graph.

NetGAN Architecture
  • The Generator: An LSTM-based network takes a latent noise vector $z$ and produces a sequence of nodes (a walk). To handle the discrete nature of node selection while remaining differentiable, the authors use the Straight-Through Gumbel-Softmax estimator.
  • The Discriminator: Another LSTM tries to distinguish between "real" random walks (sampled from the input graph) and "fake" ones produced by the generator.
  • Training: The model uses the Wasserstein GAN (WGAN) objective with a gradient penalty to ensure training stability and prevent mode collapse.
  • Graph Assembly: After training, the generator produces thousands of walks. The model counts how often an edge $(u, v)$ appears across these walks to create a score matrix, which is then thresholded or sampled to form the final synthetic adjacency matrix.

Key Insights

  • Random Walks as a Proxy: By focusing on walks, NetGAN inherently solves the permutation invariance problem. A random walk doesn't care about the global "ID" of a node; it only cares about local connectivity.
  • Memory is Crucial: While random walks are technically Markovian (the next step only depends on the current node), the authors found that using an LSTM with memory is vital. It allows the model to capture higher-order structures, like cycles and community boundaries, that a simple transition matrix would miss.
  • Generalization vs. Memorization: The authors introduced "Early Stopping" criteria to prevent the GAN from simply memorizing the input edges. This ensures the model learns the underlying distribution rather than just replicating the training data.
  • Latent Space Topology: Much like GANs for images, NetGAN’s latent space is continuous. Interpolating between two points in the latent space results in graphs with smoothly changing structural properties.

Key Results

NetGAN was evaluated on several standard graph benchmarks, including citation networks (CORA, CITESEER, PUBMED) and social networks (Political Blogs), ranging from ~1,200 to nearly 20,000 nodes.

Graph and Degree Distribution Comparison
  • Structural Fidelity: NetGAN achieved the best "Average Rank" across eight different graph statistics (like triangle count, maximum degree, and characteristic path length) compared to baselines like DC-SBM and BTER. The generated graphs visually resemble the originals and closely match their degree distributions.
  • Link Prediction: Despite not being explicitly trained for it, NetGAN achieved state-of-the-art or competitive results in link prediction. For example, on the CITESEER dataset, NetGAN achieved an AUC of 96.30%, outperforming specialized methods like node2vec and VGAE.
  • Sparsity Exploitation: Unlike models that generate $N \times N$ matrices (quadratic complexity), NetGAN only considers non-zero entries (edges) via walks, allowing it to handle graphs with thousands of nodes efficiently.

Limitations and Future Work

  • Scalability: While more efficient than $O(N^2)$ models, generating enough walks to "cover" a very large graph is computationally expensive, though the authors note this process is easily parallelizable.
  • Evaluation Metrics: Judging if a graph is "realistic" is harder than judging an image. The authors rely on statistical aggregates, but more nuanced measures of "graph realism" are needed.
  • Single Graph Constraint: The current architecture is designed to learn from one large graph. Extending this to learn from a collection of smaller, independent graphs (like molecules) remains an open area for adaptation.
  • Node Attributes: The current model only considers graph topology. Incorporating node features (text, categories, etc.) is a suggested direction for future research.

Summary updated

BibTeX
@inproceedings{bojchevski2018netgan,
  author = {Aleksandar Bojchevski and Oleksandr Shchur and Daniel Zügner and Stephan Günnemann},
  title = {{NetGAN: Generating Graphs via Random Walks}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=rkbXti-uZB},
}
Figure