Skip to main content

Converts Graph Objects between networkX, graph_tools and igraph

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 here, can be used: registry.gitlab.com/luerhard/pyintergraph.

This arch container contains a fully working installation of python 3.7 and the three network-libraries which 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

pyintergraph-1.3.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

pyintergraph-1.3.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pyintergraph-1.3.2.tar.gz.

File metadata

  • Download URL: pyintergraph-1.3.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for pyintergraph-1.3.2.tar.gz
Algorithm Hash digest
SHA256 6fa292a91bef627eda1e83797863056da02f23a7648c1299606b85dc1b26d694
MD5 bfd53ff4fa55f6b79581da87b454135c
BLAKE2b-256 471041075680b2f7530f58a204dda5a4c60b2daa45fc6e7a115708d2cc94ec19

See more details on using hashes here.

File details

Details for the file pyintergraph-1.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyintergraph-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af9c5898bdbb3422a9e1abe5eb11594236fcafb5348b9bd58c204ce8d0d277c6
MD5 d86c01ee67f35b6b6b7b563a4e32b95f
BLAKE2b-256 b4fda90e9fee4804fdf5c0fe1f62ebf294b2dabed5ecb4503782e05fed9a90e6

See more details on using hashes here.

Supported by

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