Skip to main content
gdMetriX logo

gdMetriX: Graph Drawing Quality Metrics for Python & NetworkX

gdMetriX is a Python library and NetworkX extension for computing graph drawing quality metrics — also known as graph layout aesthetics, readability metrics, or graph embedding quality measures. It implements peer-reviewed metrics from the graph drawing and information visualization literature (crossing number, crossing density, symmetry, node distribution, edge orthogonality, angular resolution, and more) so you can quantitatively evaluate, compare, and benchmark graph layouts and graph drawing algorithms.

PyPI Tests Python NumPy Downloads Coverage License GitHub Pages Paper Code style: Black PRs Welcome

📖 Full documentation · 📦 PyPI package · 📄 Cite the paper · 🕹️ Try the live graph editor

Why gdMetriX?

If you draw, lay out, embed, or visualize graphs and networks — and need to answer "how good is this layout?" — gdMetriX gives you a ready-made, tested toolkit instead of re-implementing graph drawing metrics from papers yourself:

  • Drop-in NetworkX integration — works directly with networkx.Graph / DiGraph objects and node pos attributes, no custom graph format required.
  • Broad metric coverage — crossings, area & boundary, node distribution, edge directions, and symmetry metrics, each backed by a citation to the original publication.
  • Benchmark datasets included — one-line access to the Graph Layout Benchmark Datasets, so you can evaluate algorithms on real-world graphs (subway maps, code dependency graphs, Rome graphs, chess openings, SteinLib, and more) without manually downloading and parsing data.
  • Built for research — used to support reproducible evaluation of graph layout / graph embedding algorithms; citable via a Dagstuhl / LIPIcs publication.

Typical use cases: evaluating graph layout/graph drawing algorithms, comparing force-directed vs. orthogonal vs. hierarchical layouts, scoring auto-generated diagrams, building graph visualization quality dashboards, and academic research in graph drawing and network visualization.

Table of contents

Installation

gdMetriX requires Python 3.11 or higher.

Before installing, make sure you have the latest version of pip installed:

python -m pip install --upgrade pip

To install the package using pip use the following command:

pip install gdMetriX

Examples

Working with networkX

gdMetriX works with the graph classes of networkX. For more details on how to work with networkX, please refer to their documentation.

For all graph drawing metrics, gdMetriX needs node positions, which is expected as a tuple with the attribute name ' pos'. You can set the attributes using networkX:

import networkx as nx
import gdMetriX

g = nx.Graph()
g.add_node('nodeA')
g.add_node('nodeB')
pos = {'nodeA': (0, 3.5), 'nodeB': (-3, 3)}
nx.set_node_attributes(g, pos)

Alternatively you can also set the position for a individual vertex:

g.add_node('nodeC', pos=(0, 0))

Calculating quality metrics

For a complete list of implemented metrics, please refer to the documentation.

For an example, in order to calculate the number of crossings, use:

crossings = gdMetriX.get_crossings(g)
print(len(crossings))

The node positions are automatically read from the graph. You can also supply them directly:

pos = {'nodeA': (0, 3.5), 'nodeB': (-3, 3), 'nodeC': (0, 0)}
crossings = gdMetriX.get_crossings(g, pos=pos)
print(len(crossings))

Other graph drawing metrics follow the same pattern — for example, crossing density, edge orthogonality and reflective symmetry:

crossing_quality = gdMetriX.crossing_density(g)
orthogonality = gdMetriX.edge_orthogonality(g)
symmetry_score = gdMetriX.reflective_symmetry(g)

Implemented metrics

gdMetriX implements graph drawing quality metrics across five categories. Each metric links to its implementation and the publication it is based on in the full metrics reference.

Category Example metrics
Crossings crossing number, crossing list, crossing density, crossing angles, crossing angular resolution
Area & boundary bounding box area, tight (convex hull) area, width, height, aspect ratio
Node distribution center of mass, closest pair of points/elements, concentration, homogeneity, horizontal/vertical balance, node orthogonality, Gabriel ratio
Edge directions angular resolution, average flow, upwards flow, coherence to average flow, edge orthogonality
Symmetry reflective (node-based) symmetry, edge-based symmetry, stress-based symmetry, even neighborhood distribution, visual symmetry

gdMetriX also includes supporting utilities for graph drawing research: planarization, position normalization, combinatorial embeddings, ordered neighborhoods, and heatmap generation for local metrics. See the additional features reference for details.

Loading datasets

gdMetriX supports the automatic import of graph drawing datasets. The datasets are collected from the Graph Layout Benchmark Datasets project from the Northeastern University Visualization Lab easily accessible for networkX.

The project aims to collect datasets used for graph layout algorithms and make them available for long-term access. The graphs are stored on the Open Science Foundation platform.

Information about the individual datasets can be found at the project homepage.

To get a list of all available datasets:

available_datasets = gdMetriX.get_available_datasets()
print(available_datasets)
# ['subways', 'code', 'rome', 'chess', 'steinlib', ...]

To iterate over all graphs of a given dataset, simply call gdMetriX.iterate_dataset():

for graph in gdMetriX.iterate_dataset('subways'):
    print(graph.nodes())

Interactive graph editor

Want to try gdMetriX without writing any code? The live interactive graph editor lets you draw or import a graph in your browser and see gdMetriX's quality metrics (crossings, symmetry, node distribution, edge orthogonality, and more) calculated and updated live as you edit the layout.

Documentation

The full API reference, tutorial notebooks, and the complete list of implemented graph drawing metrics are available at livus.github.io/gdMetriX.

Contributing

Contributions are welcome! Whether it's a new metric, a bug fix, a documentation improvement, or a new dataset integration, feel free to open an issue or pull request. New to the project? Start with an issue labeled "good first issue".

Citing

If you find this project useful for your work, consider citing the corresponding Dagstuhl publication.

@InProceedings{nollenburg_et_al:LIPIcs.GD.2024.45,
  author    = {N\"ollenburg, Martin and R\"oder, Sebastian and Wallinger, Markus},
  title     = {{GdMetriX - A NetworkX Extension For Graph Drawing Metrics}},
  booktitle = {32nd International Symposium on Graph Drawing and Network Visualization (GD 2024)},
  pages     = {45:1--45:3},
  series    = {Leibniz International Proceedings in Informatics (LIPIcs)},
  ISBN      = {978-3-95977-343-0},
  ISSN      = {1868-8969},
  year      = {2024},
  volume    = {320},
  editor    = {Felsner, Stefan and Klein, Karsten},
  publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f\"ur Informatik},
  address   = {Dagstuhl, Germany},
  doi       = {10.4230/LIPIcs.GD.2024.45}
}

License

The project is distributed under the GNU General Public License Version 3.

Metadata

Release files for gdMetriX 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gdMetriX 0.1.0
File Size Uploaded Provenance Actions
gdmetrix-0.1.0.tar.gz 86.8 kB With provenance Details for gdmetrix-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gdMetriX 0.1.0
File Interpreter ABI Platform Actions
gdmetrix-0.1.0-py3-none-any.whl Python 3 none any Details for gdmetrix-0.1.0-py3-none-any.whl

Total release size: 183.6 kB

Release files / gdmetrix-0.1.0.tar.gz

Download URL gdmetrix-0.1.0.tar.gz
Size 86.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5d2ef2d46de78de6071acd1f2594762429e70fe997af46c1edaa6551548be592
BLAKE2b-256 checksum
How to use checksums
7ab1be852ceb4999a19bb018ab3debd89e77d9445aeedac7f3708060894733a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / gdmetrix-0.1.0-py3-none-any.whl

Download URL gdmetrix-0.1.0-py3-none-any.whl
Size 96.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7ca8c1125a8400a2d350a041ccba90eb90febbfd05cc1ba097de27a66988fb5
BLAKE2b-256 checksum
How to use checksums
9219b51a56e59a587c27d690c511c91f5edc2fdfcfff5dbcd8ff5baa7df3a9ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for gdMetriX 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gdmetrix-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page