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.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyintergraph-1.3.1.tar.gz
Algorithm Hash digest
SHA256 aa33d986d09ec4368235fb910c846745d106f00ae9c1cd066de3202377d14abf
MD5 ab17b98b06e5ab94cd356f4700959658
BLAKE2b-256 9299bb45f4391ddf94574fbdfbbfec9ffdcb3b54a449cb33c23a9201da723fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyintergraph-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac075ea85b663deaec031b121cae876c2c29e01260dcdb98b23ed481a82b2f9b
MD5 e2b258e281d8423dd9be35821e52b153
BLAKE2b-256 5695a5786a3cd7f13fd4f729c0a301b81151aca566a0276bf51843221f14e9b9

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