Skip to main content

A small extension to networkX providing common metrics for graph drawing

Project description

gdMetriX

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

gdMetriX is an extension to networkX providing commonly used quality measures in graph drawing as well as access to some datasets used previously for evaluating graph embedding algorithms.

Installation

gdMetriX requires Python 3.9 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))

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 = get_available_datasets()
>> > print(available_datasets)
['subways', 'code', 'rome', 'chess', 'steinlib', ...

To iterate over all graphs of a given dataset, simply call :func:get_list_of_graphs():

>> > for graph in get_list_of_graphs('subways'):
    >> > print(graph.nodes())

License

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

Citing

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdmetrix-0.0.4.tar.gz (66.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gdmetrix-0.0.4-py3-none-any.whl (74.8 kB view details)

Uploaded Python 3

File details

Details for the file gdmetrix-0.0.4.tar.gz.

File metadata

  • Download URL: gdmetrix-0.0.4.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gdmetrix-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e6e18482f0a324222fe35227b88d54807d11a9ccbfc839a0095b96251eb2e74c
MD5 b9362b0478a7444a7fe55be2f80d265b
BLAKE2b-256 b020e94524aeb8cae4e7619e1f5aa958c41e433d94d429c7cba083440435bcd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for gdmetrix-0.0.4.tar.gz:

Publisher: python-publish.yml on livus/gdMetriX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gdmetrix-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: gdmetrix-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 74.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gdmetrix-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1a95aa93511ba49a7014ac5a984f1d63c36379565d0d9db3d5bcef6e76c02597
MD5 fc2cb4acf5dd0860ee0b05c412429c5c
BLAKE2b-256 a5f79ac7a1a34445f30248a9b37a7eae342dc7d802fedbbe196eb1f836bd8816

See more details on using hashes here.

Provenance

The following attestation bundles were made for gdmetrix-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on livus/gdMetriX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page