Convert Python-Graph-Objects between networkx, igraph and graph-tools
Project description
pyintergraph
Convert Python-Graph-Objects between networkx, python-igraph and graph-tools.
Installation
This package can be installed via:
pip install pyintergraph
For the note on imports and dependencies, see the section at the bottom of the page.
Usage
import networkx as nx
import pyintergraph
nx_graph = nx.karate_club_graph()
graph_tool_graph = pyintergraph.nx2gt(nx_graph, labelname="node_label")
igraph_graph = pyintergraph.gt2igraph(graph_tool_graph, labelname="node_label")
reversed_nx_graph = pyintergraph.igraph2nx(igraph_graph)
# or
Graph = pyintergraph.InterGraph.from_networkX(nx_graph)
graph_tool_graph = Graph.to_graph_tool(labelname="node_label")
igraph_graph = Graph.to_igraph()
reversed_nx_graph = Graph.to_networkX()
assert list(nx_graph.nodes(data=True)) == list(reversed_nx_graph.nodes(data=True))
assert list(nx_graph.edges(data=True)) == list(reversed_nx_graph.edges(data=True))
assert type(nx_graph) == type(reversed_nx_graph)
Versions and dependencies
This package ist built and tested with the following configuration:
- python 3.7.6
- networkX 2.4
- igraph 0.8.0
- graph_tool 2.29
A note on imports and dependencies
Because the installation of python-igraph and graph_tool can be tricky, they are not set as required dependencies for this package. As not everyone has all three packages installed, imports happen just when the two functions of interest are called. That way it is possible to convert networkX-Graphs to igraph-Graphs even when graph_tool is not installed.
Docker container
If any problems with the installation of python-igraph oder graph_tool arise, the Docker-Container which is used for testing hier can be used: registry.gitlab.com/luerhard/pyintergraph.
This arch container contains a fully working installation of python 3.7 and three network-libraries that can be converted with this tool. A Dockerfile to rebuild this image can be found in the pacakge-repository on gitlab.com/luerhard/pyintergraph
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
File details
Details for the file pyintergraph-1.2.0.tar.gz
.
File metadata
- Download URL: pyintergraph-1.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 526e291b553fe060aa4be09613b3d10e3ab896dd1754f62e9d4b2a7f60cc40a3 |
|
MD5 | 4d1e0bc9f33b66b456cf624498d64cc3 |
|
BLAKE2b-256 | 9ebc182abce8172b688e5233f3839614cb552624e78ce16057106f8d4494ef35 |
File details
Details for the file pyintergraph-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: pyintergraph-1.2.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e543635619885e5215d5c54f6989ddd2c7659bd2908b1ca20ba54c18f299c1c |
|
MD5 | 8be7e6d8ff4b730c60dc49903a69a057 |
|
BLAKE2b-256 | a45324308465f2345e040fe9d0947c67cd79fe2422c93702b0f7011116f92653 |