Skip to main content

A python graph library implemented in Rust

Project description

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 x86_64 on Mac OSX and Windows 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

retworkx-0.0.9.tar.gz (6.7 kB view details)

Uploaded Source

Built Distributions

retworkx-0.0.9-cp37-cp37m-win_amd64.whl (121.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

retworkx-0.0.9-cp37-cp37m-manylinux1_x86_64.whl (677.3 kB view details)

Uploaded CPython 3.7m

retworkx-0.0.9-cp37-cp37m-manylinux1_i686.whl (716.5 kB view details)

Uploaded CPython 3.7m

retworkx-0.0.9-cp37-cp37m-macosx_10_6_intel.whl (158.6 kB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

retworkx-0.0.9-cp36-cp36m-win_amd64.whl (122.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

retworkx-0.0.9-cp36-cp36m-manylinux1_x86_64.whl (677.5 kB view details)

Uploaded CPython 3.6m

retworkx-0.0.9-cp36-cp36m-manylinux1_i686.whl (717.0 kB view details)

Uploaded CPython 3.6m

retworkx-0.0.9-cp36-cp36m-macosx_10_6_intel.whl (158.9 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

retworkx-0.0.9-cp35-cp35m-win_amd64.whl (122.0 kB view details)

Uploaded CPython 3.5m Windows x86-64

retworkx-0.0.9-cp35-cp35m-manylinux1_x86_64.whl (677.7 kB view details)

Uploaded CPython 3.5m

retworkx-0.0.9-cp35-cp35m-manylinux1_i686.whl (717.2 kB view details)

Uploaded CPython 3.5m

retworkx-0.0.9-cp35-cp35m-macosx_10_6_intel.whl (159.1 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

File details

Details for the file retworkx-0.0.9.tar.gz.

File metadata

  • Download URL: retworkx-0.0.9.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for retworkx-0.0.9.tar.gz
Algorithm Hash digest
SHA256 0d2a2b0a3283cb9c80ad5d73f8699e2ede4934f6f5ad6321c0aa9e7387ec2914
MD5 a160e9e36b33362a2f69d3f547e60144
BLAKE2b-256 e7700d2b97a7c4b925df7f4ed51f1f537584b504804cad9a9568be074be9d3a6

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 121.8 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for retworkx-0.0.9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 44cc126f3b291a33ec42fd65954d87318449153169ead2e9cef1e5afa194ba06
MD5 47a1af49819548470a68428040310024
BLAKE2b-256 f5162af7a16e7c39471e82bd19d371af2343d14271b12cb3827eb00aa840fde3

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 677.3 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 47dd676cf717be06b3596fd42fe95e3f9aff3fbcefc3323c6d659b38ef2fd3f1
MD5 aea82c2e70e52e7cc843c038a1faa995
BLAKE2b-256 5f4d938f778c1813656a89c33eb55892205a0c0834a9865f1827bb2acf77d8c3

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 716.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 fa8ece8c8c35713ecce253bc5b46b722b92768f10ca48e3902d1c544adb68495
MD5 7616c9eace3a6277c6cb310e8d54d6e5
BLAKE2b-256 c56a67cbf4949acc092a4c25e7b8a57fe9511d7d146acd352ba2d0c1a141ff2a

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 158.6 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.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15

File hashes

Hashes for retworkx-0.0.9-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 cbf76b93e6d811f802d0e6f257bf072cd7a34d599ee16176cd206da21a842ead
MD5 0fe21c220610ef56fc2d6814896cd175
BLAKE2b-256 9553482c5f5c834e51b3eb1f60c6dd6fdf9fdc26661f51d2e3445eadcd9b04ac

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 122.1 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for retworkx-0.0.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b1df17bf90210a8b69fefa472c4c98ffdb207eef762d092cf87ba221b4c30c41
MD5 cd66a095706901b1cb072e823d8c049d
BLAKE2b-256 d68253047459aef475e234f331cea331df2b2c29854853c1be6f44e942011186

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 677.5 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 be5b4c0712cee663c16c55d8fdbc21d15cd4626d1a0d2eb1487f8922e9779230
MD5 90ca1f60c6d79b5febeceb6135afc400
BLAKE2b-256 244eca32bc92dc381875d2afe9d7942f3bd21abe867a0311b39b0246b08c13ef

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 717.0 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4fed20848ea8b94f7af11e529ffb496722cc097bccf8b75b7d24960936bd4454
MD5 3f8bdc9f3fb94e1f74d875a53c4857b7
BLAKE2b-256 2b6fe58a61911758b162607cb34ec611239f1cc1bed6a5315e5200fbd94b5c86

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: retworkx-0.0.9-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.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15

File hashes

Hashes for retworkx-0.0.9-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 5ff8878f191b2ac872ba240e002683607ebfd5b4c5e9009c86ea78b1ff8c4f3f
MD5 1a9b5e5f1a45a80e4f1da06bad9db22b
BLAKE2b-256 d5f7ca1173367ff9ead1fb031c02c2c6ae7c3a5b326d7d79cfbfa789af749939

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 122.0 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for retworkx-0.0.9-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 826fe74c158e75fb1d49a8503ab43b27b6dec62ffcec7141c8074428052bf441
MD5 3fde11c5f7f3116853f83140548f69a2
BLAKE2b-256 9b1e516f4af0664c8ea8c5cbddf24c6df7e5cbc28789f5b1f0d60d66565c9ff9

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 677.7 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 48dfd773614e94d6b16e44677583afdbd1f0de5abe29134ee024f1f18ea87cd3
MD5 0a157d3a7ee878f1972768b859085a41
BLAKE2b-256 a7d1dc1368103052b8cd9228bf48270ee3abc4e6ea215d693c64552762fda1c0

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 717.2 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.6

File hashes

Hashes for retworkx-0.0.9-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8c3a02321d005b73b9b3e0900986ddbb47fd93009c9831256b58fb9f9b3ab2db
MD5 b57e0d6343b7e92c971a64a2361961b5
BLAKE2b-256 63f69704e142a054e1e75f080cc274a5c76d2b41fa9cfe5e6e9fddc53e047373

See more details on using hashes here.

File details

Details for the file retworkx-0.0.9-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: retworkx-0.0.9-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 159.1 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.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15

File hashes

Hashes for retworkx-0.0.9-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f5924b5bcc7314f54e397cbad81ca931744e04a36f1cf580f2ff3a8df50dc628
MD5 ef7bfbd7dcaf55e858408c50027480dc
BLAKE2b-256 fdf0bcfd5db9452f6f0991d93c1581cf45956c1b36c0566bfc7e8a518aff634b

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