DeepDrawing: A Deep Learning Approach to Graph Drawing

Yong Wang, Zhihua Jin, Qianwen Wang, Weiwei Cui, Tengfei Ma, Huamin Qu

Graph drawing is a bit of a "dark art" in data visualization. If you’ve ever used tools like Gephi or D3.js, you know the drill: you pick an algorithm (like Force-Directed), and then you spend twenty minutes fiddling with "gravity," "friction," and "charge" parameters until the hairball of nodes finally looks like a network.

In their paper "DeepDrawing: A Deep Learning Approach to Graph Drawing," Yong Wang and his colleagues propose a shift in perspective. Instead of manually tuning physics simulations, why not train a neural network to learn what a "good" layout looks like and then have it draw new graphs instantly?

TL;DR

DeepDrawing is the first deep learning framework designed to map graph structures directly to 2D coordinates. By using a specialized "Graph-LSTM" and a transformation-invariant loss function, the system learns to replicate complex drawing styles (like ForceAtlas2) and generates high-quality layouts for new graphs in milliseconds.

What Problem Does This Paper Address?

Traditional graph drawing algorithms are computationally expensive and user-intensive. Most rely on iterative physical simulations or complex dimensionality reduction. For a non-expert, achieving a specific visual style—such as clearly separated communities or a perfect grid—requires tedious trial-and-error parameter tuning.

The authors identify three major hurdles to using Deep Learning (DL) for this task:

  1. Non-Euclidean Data: Graphs aren't like images or text; their nodes don't have a natural linear order.
  2. Transformation Invariance: A layout is "correct" even if it is rotated, scaled, or translated. Standard loss functions (like Mean Squared Error) would fail because they punish these harmless changes.
  3. Lack of Data: There is no "ImageNet" for graph layouts.

Methods

The researchers developed a pipeline called DeepDrawing to overcome these challenges:

  • Graph-LSTM Architecture: Standard LSTMs process data in a simple chain. To capture graph topology, the authors added "skip connections" between LSTM cells that correspond to the actual edges in the graph. This allows the model to "feel" the network's structure as it moves through the sequence.
  • BFS Node Ordering: To turn a graph into a sequence the LSTM can understand, they use Breadth-First Search (BFS). This provides a consistent way to order nodes and limits the "look-back" distance needed for the adjacency vectors.
  • Procrustes Analysis Loss: This is the "secret sauce." Instead of comparing raw coordinates, the model uses Procrustes Analysis to measure the similarity between the predicted layout and the ground truth. This metric is mathematically invariant to translation, rotation, and scaling, allowing the network to focus on the shape of the graph.
  • Bidirectional Processing: The model runs both forward and backward through the node sequence to ensure that the placement of early nodes accounts for the connections of later nodes.

Datasets

Because no standard benchmark existed, the authors synthesized their own:

  • General Graphs: 32,000 synthetic graphs (20–50 nodes) with varying community structures.
  • Special Layouts: Small sets of Grid and Star graphs to test the model's ability to learn rigid geometric patterns.
  • Ground Truths: They used established algorithms—ForceAtlas2 and PivotMDS—to generate the "labels" (the target layouts) the model was tasked to learn.

Key Insights and Ideas

  • Style as a Learned Feature: The paper demonstrates that "graph drawing style" (e.g., how much space is between clusters) can be captured by a neural network. Once trained on ForceAtlas2 results, the model consistently produces layouts that look like ForceAtlas2, without ever running a physics simulation.
  • The Power of BFS: Using BFS node ordering isn't just a convenience; it creates a "local horizon." In a BFS sequence, a node is only likely to be connected to nodes within a certain distance in the sequence, which makes the learning task much more manageable for the LSTM.
  • Decoupling Generation from Simulation: By moving the "intelligence" of the layout into the weights of a neural network, the actual generation of the drawing becomes a simple forward pass, which is incredibly fast.

Key Results

  • Visual Fidelity: DeepDrawing successfully replicated grid, star, and community-based layouts. It significantly outperformed a standard "baseline" Bi-LSTM, particularly in preserving community clusters.
  • Quantitative Success: Using aesthetic metrics (edge crossings, node occlusion, and community overlap), DeepDrawing achieved lower Root-Mean-Square Error (RMSE) compared to the baseline when measured against the ground truth.
  • Massive Speedups:
    • On a CPU, DeepDrawing was roughly 3.5x faster than ForceAtlas2.
  • On a GPU, the speedup is even more dramatic. Because neural networks are highly parallelizable, DeepDrawing can generate a layout in about 0.0008 seconds, making it nearly instantaneous for the small graphs tested.

Limitations and Future Work

  • Scalability: The current study only looked at small graphs (20–50 nodes). The authors acknowledge that larger graphs will require more complex architectures and perhaps different node-ordering strategies.
  • The "Black Box" Problem: Unlike traditional algorithms where you can adjust a "gravity" slider, a trained DeepDrawing model is fixed. If you don't like the result, you can't easily tweak a parameter; you'd likely need to retrain or fine-tune the model.
  • Sensitivity to Ordering: While BFS helps, the choice of the starting node in the BFS sequence can still influence the final layout.

DeepDrawing marks a fascinating first step into "AI-driven visualization," suggesting a future where our tools learn our aesthetic preferences rather than forcing us to learn their math.

Summary updated

BibTeX
@article{wang2020deepdrawing,
  author = {Yong Wang and Zhihua Jin and Qianwen Wang and Weiwei Cui and Tengfei Ma and Huamin Qu},
  title = {{DeepDrawing: A Deep Learning Approach to Graph Drawing}},
  journal = {IEEE Trans. Vis. Comput. Graph.},
  year = {2020},
  url = {https://openreview.net/forum?id=xgS2j4b2fCg},
}
Figure