A small extension to networkX providing common metrics for graph drawing
Project description
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6e18482f0a324222fe35227b88d54807d11a9ccbfc839a0095b96251eb2e74c
|
|
| MD5 |
b9362b0478a7444a7fe55be2f80d265b
|
|
| BLAKE2b-256 |
b020e94524aeb8cae4e7619e1f5aa958c41e433d94d429c7cba083440435bcd0
|
Provenance
The following attestation bundles were made for gdmetrix-0.0.4.tar.gz:
Publisher:
python-publish.yml on livus/gdMetriX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gdmetrix-0.0.4.tar.gz -
Subject digest:
e6e18482f0a324222fe35227b88d54807d11a9ccbfc839a0095b96251eb2e74c - Sigstore transparency entry: 187873926
- Sigstore integration time:
-
Permalink:
livus/gdMetriX@dd432271ec086b60e29cc4512ca3abb206df7246 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/livus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dd432271ec086b60e29cc4512ca3abb206df7246 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a95aa93511ba49a7014ac5a984f1d63c36379565d0d9db3d5bcef6e76c02597
|
|
| MD5 |
fc2cb4acf5dd0860ee0b05c412429c5c
|
|
| BLAKE2b-256 |
a5f79ac7a1a34445f30248a9b37a7eae342dc7d802fedbbe196eb1f836bd8816
|
Provenance
The following attestation bundles were made for gdmetrix-0.0.4-py3-none-any.whl:
Publisher:
python-publish.yml on livus/gdMetriX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gdmetrix-0.0.4-py3-none-any.whl -
Subject digest:
1a95aa93511ba49a7014ac5a984f1d63c36379565d0d9db3d5bcef6e76c02597 - Sigstore transparency entry: 187873931
- Sigstore integration time:
-
Permalink:
livus/gdMetriX@dd432271ec086b60e29cc4512ca3abb206df7246 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/livus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dd432271ec086b60e29cc4512ca3abb206df7246 -
Trigger Event:
release
-
Statement type: