A python graph library implemented in Rust
Project description
You can see the full rendered docs at: https://retworkx.readthedocs.io/en/latest/index.html
retworkx is a rust graph library interface to python3. For right now it’s scope is as an experiment in being a potential replacement for qiskit-terra’s networkx usage (hence the name). The scope might grow or change over time, but to start it’s just about building a DAG and operating on it with the performance and safety that Rust provides. It is also a personal exercise in learning how to interface rust with python.
Installing retworkx
retworkx is published on pypi so on x86_64 and i686 linux systems or Mac OSX systems installing is as simple as running:
pip install retworkx
This will install a precompiled version of retworkx into your python environment. However if there are no precompiled binaries published for your system you’ll have to compile the code. The source package is also published on pypi so you can also run the above command to install it. However, there are 2 preconditions for this to work, first you need to have cargo/rustc nightly in your PATH. You can use rustup to make this step simpler. Secondly, you need to have setuptools-rust installed in your python environment. This can can be done by simply running:
pip install setuptools-rust
prior to running:
pip install retworkx
If you have rust nightly properly installed pip will compile retworkx for your local system and it should run just as the prebuilt binaries would.
Building from source
The first step for building retworkx from source is to clone it locally with:
git clone https://github.com/mtreinish/retworkx.git
retworkx uses PyO3 and setuptools-rust to build the python interface. Unfortunately, this means you need to use nightly rust because PyO3 only works with nightly at this point. You can use rustup to install rust nightly.
Once you have nightly rust and cargo installed you can easily install retworkx into your python environment using pip. Once you have a local clone of the repo you can install retworkx into your python env with:
pip install .
Assuming your current working directory is the root of the repo. Otherwise you can run:
pip install $PATH_TO_REPO_ROOT
which will install it the same way. Then retworkx in your local python environment. There are 2 things to note when doing this though, first if you try to run python from the repo root using this method it will not work as you expect. There is a name conflict in the repo root because of the local python package shim used in building the package. Simply run your python scripts or programs using retworkx outside of the repo root. The second issue is that any local changes you make to the rust code will not be reflected live in the python you’ll need to recompile the source by rerunning pip install to have any changes reflected in your python environment.
Using retworkx
Once you have retworkx installed you can use it by importing retworkx. All the functions and the PyDAG class are off the root of the package. For example, building a DAG and adding 2 nodes with an edge between them would be:
import retworkx my_dag = retworkx.PyDAG() # add_node(), add_child(), and add_parent() return the node index # The sole argument here can be any python object root_node = my_dag.add_node("MyRoot") # The second and third arguments can be any python object my_dag.add_child(root_node, "AChild", ["EdgeData"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file retworkx-0.0.6.tar.gz
.
File metadata
- Download URL: retworkx-0.0.6.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac3196a9e27eb9007051743dc2fb720c0229893152d27dcd7b647df6f7221cc6 |
|
MD5 | fc6ed7c60efdf1e59c9422b3ee4811d6 |
|
BLAKE2b-256 | 522f3a24664bbd8add4fe35ac17ee1104530bfb753eefe4a662aaeeb5f69135a |
File details
Details for the file retworkx-0.0.6-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 116.7 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c08c1828ef74cc46ff2bd9f8716bab6d77a144a2e03ccf664893b2af7e5d2d |
|
MD5 | 2d315844c532e6a1be4dcf5c9398c56d |
|
BLAKE2b-256 | fbb1d730a2dcc6a19a610589b0095648301dbdfdf777373feaf97f0c5c9c9dff |
File details
Details for the file retworkx-0.0.6-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 503.3 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2ce5faec9e86d74bb86aba8ee517acbc3df4f071c470947d9d008f660f11250 |
|
MD5 | efc8ba4e6525231956f5643439be8cfd |
|
BLAKE2b-256 | 9d1fdb012309037f4dd2f70fa142afc22874a0136026554d63e10c4ed4d3c94b |
File details
Details for the file retworkx-0.0.6-cp37-cp37m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp37-cp37m-manylinux1_i686.whl
- Upload date:
- Size: 528.5 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2be2f27aa6763387ccedf6f83dafe2c5d9882c51be0cea05f991702f5336e74 |
|
MD5 | 46b41a8394bbcd66872db5b1f172ec87 |
|
BLAKE2b-256 | b280e46d25758a12ed9b4d02c1dbd5917d780bc7bbc116515aac22d1481f15c6 |
File details
Details for the file retworkx-0.0.6-cp37-cp37m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp37-cp37m-macosx_10_6_intel.whl
- Upload date:
- Size: 156.2 kB
- Tags: CPython 3.7m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6adef25a23fa8ea17100b2dc5c6cce6e151600c6f0de2c3fabd6ee1bb3d5ef6f |
|
MD5 | 2a9116589997041b2beaf2d7cf6eddd6 |
|
BLAKE2b-256 | 4269f372afa4f88bd74b1262d2bf9becc246c752733726f6c1a81aedb98e5962 |
File details
Details for the file retworkx-0.0.6-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 116.9 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab6d946bc1d61844b34352c9924824759f2b044a82ad2c5b7a8530b845199355 |
|
MD5 | 1448b595ea2f49e45ffaea3420a7222c |
|
BLAKE2b-256 | 98286255e965ee8e95d033d3ffae948597c59c772e4e9f141978fddfe956fc5f |
File details
Details for the file retworkx-0.0.6-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 503.5 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6d15a43a4e631f4b70abbf6f4000151f8d3a864a742b4494cb43137506357f5 |
|
MD5 | 1070f4cbdb56b8bcdefe558c9039eb86 |
|
BLAKE2b-256 | ae88ed5bef070e1b975b91d13e913cec941ababf9026b8be8b15ca8cd8176c84 |
File details
Details for the file retworkx-0.0.6-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 528.9 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b9570a7417ff4869f94c4d74a46f688178378719b2f41d27e2b6a4abab5399 |
|
MD5 | 07db827d5846936d0abbd6ed00a4b9ee |
|
BLAKE2b-256 | cec94fdc92320af81f179dae3c00d40f6babde4312f6491060830147bf1b1451 |
File details
Details for the file retworkx-0.0.6-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 156.5 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9433846bb1b50f9fc39d0d194119d0f52eca57e071494e1c0219653a3925a66 |
|
MD5 | 49a95a583cb6a9f0d35239d8fd93284a |
|
BLAKE2b-256 | f78664e7292978835489c53c142966fde81e0fe5ca39b18d7c2d625d74e7b891 |
File details
Details for the file retworkx-0.0.6-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 117.2 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d760af3d58188b17c392c1cf84810cd7dee1127b604ae81f575b943e905d783c |
|
MD5 | 8e87073dfe44320a356733d161e896ad |
|
BLAKE2b-256 | 55e51613b89e84fdd4b202c27b6a42049ef44bbdb7d477478d99f3c4bdabda6b |
File details
Details for the file retworkx-0.0.6-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 503.5 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 581bd8837d815cf63f71b71b98ed48eec1dadbb5484662073094048998aa6735 |
|
MD5 | e09502c5246c230ca916d2e98cf1e19d |
|
BLAKE2b-256 | 338a485a8ca0c62881263cb35eb098f6c0f9a85b47828dc33dcccf897889c03a |
File details
Details for the file retworkx-0.0.6-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 528.6 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c908ba0ee9440a37333b94c3c09909d2cb67a68d8e1685823ab84955b6ccd24c |
|
MD5 | df2d81aeda3aa230ace812124fe657a4 |
|
BLAKE2b-256 | bcbf69ac2756834939628d60b42e23e5eb8063b194c4431b119848573c59641e |
File details
Details for the file retworkx-0.0.6-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.6-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 156.4 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd79bde409b7ab3f7cb0423634638f3bacbccc6d8b661a859ed8dbdc70e1c4f6 |
|
MD5 | b5e556cfd3f6d51757db0c03d3c5a66c |
|
BLAKE2b-256 | cd68121446b9be4df632f79878ebf6d023ceb661ae3b5f1631bb40f8f604385c |