Partition and Code: learning how to compress graphs

Giorgos Bouritsas, Andreas Loukas, Nikolaos Karalias, Michael M. Bronstein

The Challenge of Graph Compression

Lossless compression is fundamentally about modeling the underlying distribution of data: the better you can predict the data, the fewer bits you need to store it. While highly efficient compressors exist for ordered data like text (sequences) and images (grids), graphs present a unique nightmare for compression algorithms.

Conventional compression algorithms struggle with graphs due to three primary hurdles:

  1. Graph Isomorphism (GI): Graphs lack a natural ordering. Two graphs can look entirely different in memory but be structurally identical. An optimal compressor should assign them the same code, but checking for this identity is computationally expensive.
  2. Evaluating Likelihood: To compress optimally, one must know the probability of a specific graph appearing. In high-dimensional spaces like large networks, estimating these probabilities is incredibly difficult.
  3. Model Complexity: While massive neural networks can model graph distributions, the network's weights must be included in the "compressed" file so the decoder can function. Often, these weights are larger than the data itself, negating any compression gains.

The Partition and Code (PnC) Framework

To overcome these challenges, the authors propose the Partition and Code (PnC) framework. Instead of making rigid assumptions about the graph distribution or trying to predict the entire graph's likelihood directly, PnC formulates the compressor as a probabilistic model learned from data.

The framework breaks the problem into three distinct, learnable steps:

1. Partitioning

A parametric algorithm—often a Graph Neural Network (GNN)—decomposes the large graph into a set of non-overlapping subgraphs and the "cuts" (edges) that connect them.

A molecular graph partitioned into distinct subgraphs (colored nodes) connected by cut edges (red lines), illustrating the first step of the PnC framework.

2. The Graph Dictionary

The framework maintains a dictionary of "atoms"—small, recurring subgraphs. If a partitioned subgraph matches a dictionary atom, it is encoded using a simple, lightweight index. If it is a rare structure, it is encoded using a "null model" (a basic probabilistic baseline).

3. Entropy Encoding

Finally, an entropy encoder translates these indices and cut-edge descriptions into a compressed bitstream.

Key Innovations

Unlike previous neural compressors, PnC uses neural networks to learn how to partition the graph rather than memorizing the graph itself. This is a clever workaround for the model complexity problem: the decoder does not need the full GNN to unpack the data; it only needs the small dictionary and the resulting indices. Furthermore, by restricting dictionary atoms to a small size, the authors make the Graph Isomorphism problem computationally tractable.

The framework is trained using the Minimum Description Length (MDL) principle. It seeks the perfect balance between a complex dictionary (which models the data well but is expensive to store) and a simple one (which is cheap to store but models the data poorly). Consequently, the dictionary acts as a motif-discovery tool. In molecular datasets, for example, PnC naturally identifies carbon cycles and functional groups as the most "efficient" atoms to store.

Empirical Results and Theoretical Superiority

The authors prove theoretically that, under mild conditions, PnC achieves compression gains that grow linearly or even quadratically with the number of vertices compared to standard encodings. This is because PnC exploits the community structure and repetitiveness inherent in most real-world graphs.

Empirically, PnC was evaluated across diverse domains, including molecular graphs (MUTAG, PTC, ZINC), bioinformatics (PROTEINS), and social networks (IMDB-B, IMDB-M). It consistently outperformed baselines in terms of bits per edge (bpe):

  • Molecular Graphs: On the ZINC dataset, PnC achieved ~2.07 bpe. In stark contrast, standard neural models like GraphRNN were effectively useless for compression, requiring over 43 bpe once model parameters were accounted for.
  • Social Networks: PnC combined with Stochastic Block Model (SBM) partitioning performed best, demonstrating that the framework can adapt its partitioning strategy to the specific "flavor" of the data (e.g., community-heavy social graphs vs. motif-heavy molecules).
  • Generalization: The model showed a strong ability to generalize, effectively compressing unseen graphs from the same distribution.

Limitations and Future Directions

While PnC represents a major step forward in machine learning-driven graph compression, several areas remain open for future research. First, while the partitioning step is $O(n)$, the current implementation may struggle with massive, single-instance networks (like a global social media graph) due to memory constraints during GNN training. Second, the "Neural Partitioning" module is currently a proof-of-concept; more sophisticated, differentiable partitioning algorithms could further improve compression ratios. Finally, while the Graph Isomorphism problem is solved for the small subgraphs within the dictionary, solving it for the macro-graph structure remains an open challenge.

Summary updated

BibTeX
@inproceedings{bouritsas2021partition,
  author = {Giorgos Bouritsas and Andreas Loukas and Nikolaos Karalias and Michael M. Bronstein},
  title = {{Partition and Code: learning how to compress graphs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=qL_juuU4P3Y},
}
Figure