Skip to main content

pyintergraph

Convert Python-Graph-Objects between networkx, python-igraph and graph-tool.

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)

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.

Metadata

Release files for pyintergraph 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyintergraph 1.3.3
File Size Uploaded
pyintergraph-1.3.3.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyintergraph 1.3.3
File Interpreter ABI Platform
pyintergraph-1.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / pyintergraph-1.3.3.tar.gz

Download URL pyintergraph-1.3.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2ba5396f497149d3179d400effd8ede5634ca3304ce7458ed350017f1cbe05fc
BLAKE2b-256 checksum
How to use checksums
a6e7788d3652dc44fcaf2f05bee55505f1b4658510abb7346c09042cdd73dc08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.12.0 Linux/6.5.11-300.fc39.x86_64

Release files / pyintergraph-1.3.3-py3-none-any.whl

Download URL pyintergraph-1.3.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15dbdf31659ded9fd0e1ee0155e7e7b8fbeae07b26794ef0bd260b3fdb32e861
BLAKE2b-256 checksum
How to use checksums
6ba5e69102d4aca2414954e7e04ba8bd858fa66f6b839fd85bc8f0aa4359beb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.12.0 Linux/6.5.11-300.fc39.x86_64

Release history Release notifications | RSS feed

This release

1.3.3 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page