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.5.tar.gz
.
File metadata
- Download URL: retworkx-0.0.5.tar.gz
- Upload date:
- Size: 6.1 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 | 3783ec8bcd0ec8abaa7f0bfd913acf0012ce4aaedfa2d9fdd9d6c70f862f2170 |
|
MD5 | 293a54bebe6545b06929ccaa663028ef |
|
BLAKE2b-256 | 4635ef57c6587889bf2b6f3813df57db1bddf46748aaa81a13b29fa640b4fdaf |
File details
Details for the file retworkx-0.0.5-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 502.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 | 712b73734894f5ac2ef0e9c958960b0af729e3a09b4d2fb99919dcba93de273f |
|
MD5 | 33fa60f0f3f2ad89de4e0d76fed270ee |
|
BLAKE2b-256 | 5191e7938f83991385235e67c558ea41ccf1e331938051d6c88a261803a888dd |
File details
Details for the file retworkx-0.0.5-cp37-cp37m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp37-cp37m-manylinux1_i686.whl
- Upload date:
- Size: 526.9 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 | 0248811547016ac27c7f50da2a73041fe213b501fc454ab11c01954ce1d22d81 |
|
MD5 | 856ccacbb2e4e3d37c799d7f579fb283 |
|
BLAKE2b-256 | f27e18c752c9b0e866381133c8c2f2939e616699492b0697903e29afb21f56fc |
File details
Details for the file retworkx-0.0.5-cp37-cp37m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp37-cp37m-macosx_10_6_intel.whl
- Upload date:
- Size: 158.5 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 | 45796c73f9323aaff0caa0f1a00a9e71c8db84af2578f240aa25239ff85399a1 |
|
MD5 | 3a1c922395aeca34dfafcf353429791a |
|
BLAKE2b-256 | 90e1774bd356b05ef16a38ce4379642083440ac6416cba5d6e1371870bcb307a |
File details
Details for the file retworkx-0.0.5-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 502.8 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 | 9fe1396cb599c2724c26a3deee4907f71f21d866ead8e6ffcb8533e10a76f5bc |
|
MD5 | e4b14390dd2fee0b974c05ceeed8412d |
|
BLAKE2b-256 | 5a45c97784cf0633a463591072625218efe80da3007b6efa345152d1fede1032 |
File details
Details for the file retworkx-0.0.5-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 527.4 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 | 83fd7e649408305f139d0e9bc401dcb60dfac14d47bedddba9feb8831a07da16 |
|
MD5 | 013a4f3e149c36c0c0998b887c2486af |
|
BLAKE2b-256 | e393a339586d0784431e3aadf2a1793fe9b4b67c3d137b25e06d06c96e712e1f |
File details
Details for the file retworkx-0.0.5-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 158.9 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 | 90630f9a40caedf63d882ba3a8e71eeb513ce79f2a5458030fef4029a85d99b8 |
|
MD5 | 05d895a4ad3a16eda2831a788fad62f3 |
|
BLAKE2b-256 | 5a9d2249029440fac716e025c3c0c68c914d9bbfae6995122206fcf8b56b5730 |
File details
Details for the file retworkx-0.0.5-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 502.8 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 | 82753efca6ac52d05c79ce775da67613b2822c5ba89093c1babb48684ac96df4 |
|
MD5 | 4c5c9af5cc56f74bec8c3ffd29cf383d |
|
BLAKE2b-256 | 5bdfb87af6fc419fbbe0e729084be5cb6e88f035c7a555ba4fc5e3095343bde1 |
File details
Details for the file retworkx-0.0.5-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 527.1 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 | dd48c01cc71e5f162831c75c11ccb116df02e35e79f1c91824ff0f6e16527071 |
|
MD5 | aef6dfedabd222628233f58432001724 |
|
BLAKE2b-256 | 7db9eb7f2f94ced996951087e7084062ac0fabf76594eb3d18cfa3668c91b77f |
File details
Details for the file retworkx-0.0.5-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: retworkx-0.0.5-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 158.7 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 | ea3c8aaf73a9e5d8a7f01020109f0b53fa58a4703c9e9e3350a7bd4b33f2dffe |
|
MD5 | a85ad55b963501b7f66bbfda8a403b05 |
|
BLAKE2b-256 | ac30a8091f5565f71ada92ffdf60dac24cf7c8358a6f3b179ca941288da26d28 |