Skip to main content

Exchange Python-Graph-Objects between networkx, igraph and graph-tool

Project description

# pyintergraph

Exchange 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

```python
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 = pytintergraph.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
- networkX 2.2
- python-igraph 0.7.1
- graph_tool 2.27

## 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](https://gitlab.com/luerhard/pyintergraph/container_registry).

This ubuntu:xenial 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](https://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.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pyintergraph-1.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyintergraph-1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for pyintergraph-1.1.tar.gz
Algorithm Hash digest
SHA256 69f7b272f8fdff9516c0926f4f55f681cf11a0ec3e99d653337642248e271e44
MD5 c83d6cc52b25802f8028bf326e99f164
BLAKE2b-256 5347f3adc3cc338595e8917682641f72c2353d047cfb8db714cfe393bdb4ed13

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyintergraph-1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for pyintergraph-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 804282afee9f2403c100074d684be5a4ae7b90f29609c833183cf5b696938cdf
MD5 5ea4e7fa26ab544c54db86b701726627
BLAKE2b-256 b2c5308c415406162473f5a6358f18d1090162f82df68bbe15c11e7c82dd1dce

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