graph2vec: Learning Distributed Representations of Graphs

Annamalai Narayanan, Mahinthan Chandramohan, Rajasekar Venkatesan, Lihui Chen, Yang Liu, Shantanu JaiswalarXiv 2017

TL;DR

This paper introduces graph2vec, a novel unsupervised neural embedding framework that learns fixed-length vector representations for entire graphs. Unlike previous methods that focused on substructures or relied on handcrafted features, graph2vec treats graphs like documents and learns data-driven, task-agnostic embeddings, achieving competitive results in graph classification and clustering.

What Problem Does This Paper Address?

Many real-world applications, such as social network analysis, cybersecurity, and bioinformatics, deal with graph-structured data. However, standard machine learning algorithms require fixed-length feature vectors as input. While graph kernels can provide a measure of similarity between graphs, they often rely on handcrafted features (like shortest paths or graphlets) which can lead to poor generalization and don't directly provide usable embeddings for general-purpose ML models. Existing methods that learn embeddings for graph substructures (like nodes or paths) cannot easily be extended to represent entire graphs effectively. This leaves a gap for methods that can learn comprehensive, data-driven, and versatile representations for whole graphs.

Methods

graph2vec is inspired by the success of neural document embedding models like doc2vec. The core idea is to treat each graph as a "document" and "rooted subgraphs" (neighborhoods around a node up to a certain degree) as "words." The paper leverages the skipgram model, a popular technique for learning word embeddings, to learn graph embeddings.

Here's a breakdown of the key components:

  • Rooted Subgraph Extraction: The paper uses the Weisfeiler-Lehman (WL) relabeling strategy to extract rooted subgraphs. This method is chosen because rooted subgraphs capture non-linear substructures and higher-order neighborhood information, which are considered richer representations compared to linear substructures like random walks.
  • Skipgram Model Adaptation: Similar to how doc2vec uses a document ID to predict context words, graph2vec uses a graph ID to predict its constituent rooted subgraphs. This is trained using the skipgram objective, aiming to learn embeddings where graphs composed of similar subgraphs are closer in the embedding space.
  • Negative Sampling: To efficiently train the model, especially with a large vocabulary of subgraphs, graph2vec employs negative sampling. This technique involves randomly selecting a small subset of "negative" subgraphs that are not in the graph's context to update embeddings, making the training process much faster than considering the entire vocabulary.
  • Unsupervised and Task-Agnostic: Crucially, graph2vec learns these embeddings in an unsupervised manner, meaning it doesn't require labeled graph data. The resulting embeddings are also task-agnostic, meaning they can be used for various downstream tasks like classification, clustering, or even as initializations for supervised learning methods.

Datasets

The paper evaluates graph2vec on several datasets:

  • Benchmark Graph Classification Datasets: MUTAG, PTC, PROTEINS, NCI1, and NCI109. These are standard datasets in graph machine learning, often used for chemo- and bioinformatics tasks.
  • Real-World Datasets:
    • Malware Detection: A large dataset of API Dependency Graphs (ADGs) for malicious and benign Android apps. These graphs are significantly larger than benchmark datasets, with thousands of nodes and edges.
  • Malware Familial Clustering: A dataset of ADGs from malware samples, labeled by their family. This dataset is used to evaluate clustering performance.

Key Insights and Ideas

  • Graphs as Documents: The analogy between graphs and documents, and rooted subgraphs and words, is a powerful conceptual leap that allows leveraging established NLP techniques.
  • Rooted Subgraphs are Key: The choice of rooted subgraphs over simpler substructures (like nodes or linear walks) is critical. They capture richer structural information and non-linearity, leading to better representations.
  • Unsupervised Learning is Viable for Whole Graphs: The success of graph2vec demonstrates that learning meaningful, task-agnostic embeddings for entire graphs without supervision is achievable and effective.
  • Substructure Embeddings Fall Short for Whole Graphs: The experiments clearly show that simply averaging node embeddings (like in node2vec) or using substructure-based methods (like sub2vec) does not yield competitive results for whole-graph tasks, highlighting the need for a dedicated whole-graph embedding approach.

Key Results

  • Graph Classification: graph2vec achieved state-of-the-art or competitive accuracy on benchmark datasets, outperforming substructure embedding methods and matching graph kernels. On larger, real-world malware detection tasks, graph2vec achieved 98.16% accuracy, outperforming substructure methods by over 17% and graph kernels by nearly 2%.
  • Graph Clustering: In malware familial clustering, graph2vec achieved an Adjusted Rand Index (ARI) of 56.28%, significantly outperforming substructure embedding methods (around 15%) and graph kernels (around 50%).
  • Efficiency: While not the fastest, graph2vec's pre-training time was found to be more scalable than Deep WL kernel and sub2vec, offering a good balance between performance and computational cost.

Limitations and Future Work

  • Computational Cost: While more efficient than some methods, graph2vec's pre-training can still be computationally intensive for very large graphs, though it's noted to be more scalable than Deep WL kernel and sub2vec.
  • Hyperparameter Tuning: The paper mentions that learning rate and embedding dimensions are empirically tuned, suggesting that optimal performance might depend on careful hyperparameter selection.
  • Future Work: The authors suggest that graph2vec embeddings can be used to "seed" supervised representation learning approaches, implying potential for hybrid models. The availability of code and data for graph2vec suggests future research can build upon this framework.

Summary updated

BibTeX
@misc{narayanan2017graph,
  author = {Annamalai Narayanan and Mahinthan Chandramohan and Rajasekar Venkatesan and Lihui Chen and Yang Liu and Shantanu Jaiswal},
  title = {{graph2vec: Learning Distributed Representations of Graphs}},
  year = {2017},
  eprint = {1707.05005},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1707.05005},
}
Figure