Skip to main content

A python graph library implemented in Rust

Project description

rustworkx

License Build Status Build Status Coverage Status Minimum rustc 1.70 DOI arXiv Zenodo

A high-performance, general-purpose graph library for Python, written in Rust.

Usage

Once installed, simply import rustworkx. All graph classes and top-level functions are accessible with a single import. To illustrate this, the following example calculates the shortest path between two nodes A and C in an undirected graph.

import rustworkx

# Rustworkx's undirected graph type.
graph = rustworkx.PyGraph()

# Each time add node is called, it returns a new node index
a = graph.add_node("A")
b = graph.add_node("B")
c = graph.add_node("C")

# add_edges_from takes tuples of node indices and weights,
# and returns edge indices
graph.add_edges_from([(a, b, 1.5), (a, c, 5.0), (b, c, 2.5)])

# Returns the path A -> B -> C
rustworkx.dijkstra_shortest_paths(graph, a, c, weight_fn=float)

Installing rustworkx

rustworkx is published on PyPI so on x86_64, i686, ppc64le, s390x, and aarch64 Linux systems, x86_64 on Mac OSX, and 32 and 64 bit Windows installing is as simple as running:

pip install rustworkx

This will install a precompiled version of rustworkx into your Python environment.

Installing on a platform without precompiled binaries

If there are no precompiled binaries published for your system you'll have to build the package from source. However, to be able able to build the package from the published source package you need to have Rust >= 1.70 installed (and also cargo which is normally included with rust) You can use rustup (a cross platform installer for rust) to make this simpler, or rely on other installation methods. A source package is also published on pypi, so you still can also run the above pip command to install it. Once you have rust properly installed, running:

pip install rustworkx

will build rustworkx for your local system from the source package and install it just as it would if there was a prebuilt binary available.

[!NOTE]
To build from source you will need to ensure you have pip >=19.0.0 installed, which supports PEP-517, or that you have manually installed setuptools-rust prior to running pip install rustworkx. If you receive an error about setuptools-rust not being found you should upgrade pip with pip install -U pip or manually install setuptools-rust with pip install setuptools-rust and try again.

Optional dependencies

If you're planning to use the rustworkx.visualization module you will need to install optional dependencies to use the functions. The matplotlib based drawer function rustworkx.visualization.mpl_draw requires that the matplotlib library is installed. This can be installed with pip install matplotlib or when you're installing rustworkx with pip install 'rustworkx[mpl]'. If you're going to use the graphviz based drawer function rustworkx.visualization.graphviz_drawer first you will need to install graphviz, instructions for this can be found here: https://graphviz.org/download/#executable-packages. Then you will need to install the pillow Python library. This can be done either with pip install pillow or when installing rustworkx with pip install 'rustworkx[graphviz]'.

If you would like to install all the optional Python dependencies when you install rustworkx you can use pip install 'rustworkx[all]' to do this.

Authors and Citation

rustworkx is the work of many people who contribute to the project at different levels. If you use rustworkx in your research, please cite our paper as per the included BibTeX file.

Community

Besides Github interactions (such as opening issues) there are two locations available to talk to other rustworkx users and developers. The first is a public Slack channel in the Qiskit workspace, #rustworkx. You can join the Qiskit Slack workspace here. Additionally, there is an IRC channel #rustworkx on the OFTC IRC network

Building from source

The first step for building rustworkx from source is to clone it locally with:

git clone https://github.com/Qiskit/rustworkx.git

rustworkx uses PyO3 and setuptools-rust to build the python interface, which enables using standard python tooling to work. So, assuming you have rust installed, you can easily install rustworkx into your python environment using pip. Once you have a local clone of the repo, change your current working directory to the root of the repo. Then, you can install rustworkx into your python env with:

pip install .

Assuming your current working directory is still the root of the repo. Otherwise you can run:

pip install $PATH_TO_REPO_ROOT

which will install it the same way. Then rustworkx is installed 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 rustworkx 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 your python environment, you'll need to recompile rustworkx by rerunning pip install to have any changes reflected in your python environment.

Develop Mode

If you'd like to build rustworkx in debug mode and use an interactive debugger while working on a change you can use python setup.py develop to build and install rustworkx in develop mode. This will build rustworkx without optimizations and include debuginfo which can be handy for debugging. Do note that installing rustworkx this way will be significantly slower then using pip install and should only be used for debugging/development.

[!TIP] It's worth noting that pip install -e does not work, as it will link the python packaging shim to your python environment but not build the rustworkx binary. If you want to build rustworkx in debug mode you have to use python setup.py develop.

Project history

Rustworkx was originally called retworkx and was created initially to be a replacement for Qiskit's previous (and current) NetworkX usage (hence the original name). The project was originally started to build a faster directed graph to use as the underlying data structure for the DAG at the center of qiskit's transpiler. However, since it's initial introduction the project has grown substantially and now covers all applications that need to work with graphs which includes Qiskit.

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

rustworkx-0.16.0.tar.gz (349.5 kB view details)

Uploaded Source

Built Distributions

rustworkx-0.16.0-cp39-abi3-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

rustworkx-0.16.0-cp39-abi3-win32.whl (1.8 MB view details)

Uploaded CPython 3.9+Windows x86

rustworkx-0.16.0-cp39-abi3-musllinux_1_2_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

rustworkx-0.16.0-cp39-abi3-musllinux_1_2_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

rustworkx-0.16.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

rustworkx-0.16.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

rustworkx-0.16.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

rustworkx-0.16.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

rustworkx-0.16.0-cp39-abi3-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rustworkx-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file rustworkx-0.16.0.tar.gz.

File metadata

  • Download URL: rustworkx-0.16.0.tar.gz
  • Upload date:
  • Size: 349.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rustworkx-0.16.0.tar.gz
Algorithm Hash digest
SHA256 9f0dcb83f38d5ca2c3a683eb9b6951c8aec3262fbfe5141946a7ee5ba37e0bb6
MD5 5dd026af0f8ba38fa43dfe21a7b6535d
BLAKE2b-256 a5c46d6ef39e57610d54c5f106dc3dece9eebce8b9d52d561ae092e3aede1b66

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0.tar.gz:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: rustworkx-0.16.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 905df608843c32fa45ac023687769fe13056edf7584474c801d5c50705d76e9b
MD5 91ec0d30178fe8ad02c821134e445716
BLAKE2b-256 3e799bdd52d2a33d468c81c1827de1b588080cb055d1d3561b194ab7bf2635b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-win_amd64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-win32.whl.

File metadata

  • Download URL: rustworkx-0.16.0-cp39-abi3-win32.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 040c4368729cf502f756a3b0ff5f1c6915fc389f74dcc6afc6c3833688c97c01
MD5 7e72462638f57e5dbbb1369cffd7ff38
BLAKE2b-256 6dfd9c71e90f8cde76fed95dbc1e7d019977b89a29492f49ded232c6fad3055f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-win32.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 293180b83509ee9bff4c3af7ccc1024f6528d61b65d0cb7320bd31924f10cb71
MD5 a9144fbd2a27a0e07a72615e39c5d8f9
BLAKE2b-256 6704741ed09c2b0dc0f360f85270c1179ed433785372ac9ab6ab26d3dd3ae02d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d650e39fc1a1534335f7517358ebfc3478bb235428463cfcd7c5750d50377b33
MD5 8a2733fcddcbd7770c066fb3b91d1f3f
BLAKE2b-256 3c79e3fcff21f31253ea85ef196bf2fcabad7802b11468f7d3a5d592cd0ac789

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-musllinux_1_2_aarch64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec0c12aac8c54910ace20ac6ada4b890cd39f95f69100514715f8ad7af9041e4
MD5 6bd289ca3e5cf57deb80887b4c297198
BLAKE2b-256 4fe2e21187b255c6211d71db0d08a44fc16771038b2af41712d66c408d9bec16

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 89efd5c3a4653ddacc55ca39f28b261d43deec7d678f8f8fc6b76b5087f1dfea
MD5 73f8ecffc56e608e9639cda0b28852f3
BLAKE2b-256 b53b1125e7eb834f4408bcec3cee79947efd504c715fb7ab1876f8cd4bbca497

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4f12a13d7486234fa2a84746d5e41f436bf9df43548043e7a232f48804ff8c61
MD5 4d05b61992ac81bffaecbc2f4b1fe7b1
BLAKE2b-256 59d21bc99df831c132c4b7420a85ce9150e065f4c993798f31b6a4229f238398

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 0db3a73bf68b3e66c08322a2fc95d3aa663d037d9b4e49c3509da4898d3529cc
MD5 5ec00bfca2ecd879703c2ccdf143d464
BLAKE2b-256 c642a6d6b3137be55ef1d887becdf6b64b0917c7d437bd483065a88500a55603

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bef2ef42870f806af93979b457e240f6dfa4f867ca33965c620f3a804409ed3a
MD5 8a14a43ed0c4e860297a5c420fba9a14
BLAKE2b-256 94477e7c37fb73efcc87be6414b235534605c4008a4cdbd92a61db23b878eecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustworkx-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 476a6c67b0142acd941691943750cc6737a48372304489969c2b62d30aaf4c27
MD5 164395c9ea4c59c79688cd597285fb96
BLAKE2b-256 f87036f5916aee41ffe4f604ad75742eb1bb1b849fb568e010555f9d159cd93e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on Qiskit/rustworkx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page