Skip to main content

A High-Performance Graph Library for Python

Project description

rustworkx

License Build Status Build Status Coverage Status Minimum rustc 1.85 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 to build the package from the published source package you need to have Rust >= 1.85 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 maturin>=1.9 prior to running pip install rustworkx. If you receive an error about maturin not being found you should upgrade pip with pip install -U pip or manually install maturin with pip install -U maturin>=1.9 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.

Conda Ecosystem

Community-supported binaries are published to conda-forge. Although unofficial, they can be helpful for users of the conda ecosystem (including mamba, micromamba, and pixi). To install, simply run:

conda install -c conda-forge rustworkx

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 maturin 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 run maturin build --profile dev to build rustworkx and then install the wheel with pip. This will build rustworkx without optimizations and include debuginfo when running pip install. That can be handy for debugging.

[!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.

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 its 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.18.0.tar.gz (894.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustworkx-0.18.0-cp314-cp314t-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

rustworkx-0.18.0-cp314-cp314t-musllinux_1_2_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

rustworkx-0.18.0-cp314-cp314t-manylinux_2_28_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ ARM64

rustworkx-0.18.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

rustworkx-0.18.0-cp314-cp314t-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

rustworkx-0.18.0-cp314-cp314t-macosx_10_15_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.14tmacOS 10.15+ x86-64

rustworkx-0.18.0-cp310-abi3-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

rustworkx-0.18.0-cp310-abi3-win32.whl (2.1 MB view details)

Uploaded CPython 3.10+Windows x86

rustworkx-0.18.0-cp310-abi3-musllinux_1_2_x86_64.whl (2.4 MB view details)

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

rustworkx-0.18.0-cp310-abi3-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

rustworkx-0.18.0-cp310-abi3-manylinux_2_28_s390x.whl (3.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ s390x

rustworkx-0.18.0-cp310-abi3-manylinux_2_28_ppc64le.whl (2.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ppc64le

rustworkx-0.18.0-cp310-abi3-manylinux_2_28_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rustworkx-0.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.4 MB view details)

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

rustworkx-0.18.0-cp310-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

rustworkx-0.18.0-cp310-abi3-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: rustworkx-0.18.0.tar.gz
  • Upload date:
  • Size: 894.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustworkx-0.18.0.tar.gz
Algorithm Hash digest
SHA256 5ca9cf8dbee50f8def012119ebb64771ae86916993417415aba9e845831cb436
MD5 b12876a8d20aa64749b8eb43d578bf7f
BLAKE2b-256 ff1a545aa3a3e251e9da00e4acf0e5472b7fbbb15360f56d9d5342c1f93b8b93

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.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.18.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ba9e9f91d0d14d21666f0d7549f4d8ed70dc84bf75483c68eee5a005ed900f3e
MD5 61e42b76d8ea9db74ff021098d785785
BLAKE2b-256 9947621b56c3f10138a02da9dfd636780ec9311c821fff1acf43be7292408625

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-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.18.0-cp314-cp314t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8437bca6adff8e91089bd5d176ef8a499085135031e2d2df4132821578e94dd6
MD5 ad0cc66c51011f14f6fe2cebd35ee859
BLAKE2b-256 bf96888c7849d20b7e49d978cfe9bdd8873d709e220a09f8f6bdce226ef7c2be

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-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.18.0-cp314-cp314t-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f562d5eeb2943024c85f631df713e7873ea8b572ada9044be82f29f923c1463a
MD5 965fe737e54c8fcd608943f5eb220525
BLAKE2b-256 bdeb58ed5f78ca608156ac2ce3166e41976c32345bbc36e71a3fc18390cc4de2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-manylinux_2_28_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.18.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f7099bf90fc1a7ad1789bc126e3e208d9944af2dd9f9b28f75ae148c68aa00cb
MD5 e8b2fa7e2921da2652ac6c2ae4049f65
BLAKE2b-256 c57804733471aa616dc0bc76f2c2e65ad89bb4ecbbfd2309231347c293906181

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_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.18.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d51ff00fa72144813c2af33c673b7faf7182ca0ffc85cf35569b5ac4de84bc3e
MD5 80046c9528e63a23d8a07303028f706d
BLAKE2b-256 7d1bc665d30c132e73d69ca95cf552179608de6f94434ee5eb321297ef393920

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-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.18.0-cp314-cp314t-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp314-cp314t-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bba66b268e94efd9181d49241b2547d783770dcea9ee8c64609306a7b20ace74
MD5 032fb5f26fef8502ebd3f614aaca1b59
BLAKE2b-256 f4eb147e86d56de0511ee7526e5cdf6144013d9c71ba4d6ed6dcd82b6b545861

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp314-cp314t-macosx_10_15_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.18.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rustworkx-0.18.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 602df896b4479b83c6456f702f8ba2ac1cbb972b30723d5fe2e84e6ff3de7d70
MD5 3e79b13821cd800b60ca2ebc503aa2d8
BLAKE2b-256 991bb0dc8d3751c0c58d16db72bff2954a9d3871c166147007590a3aaec4d42e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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.18.0-cp310-abi3-win32.whl.

File metadata

  • Download URL: rustworkx-0.18.0-cp310-abi3-win32.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 eb87a45864ffe36e4d86e826d12bb54dac9e4f76c214997dee624281d8711684
MD5 9e570ffc2c191c745304df40ce694625
BLAKE2b-256 5db34d159b33bbc73dbebad050a0226dcfb0753d7f05fa55a8d5351e85c8c953

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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.18.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 03dd1ab42974bc0ff957eccc330c0c0d9887d88240c0cd050039e215af5a3c45
MD5 cde42dfba9f1e6d620757529aa397b55
BLAKE2b-256 197b9df6a80162e6f90fd9945e3f8063c2aa41285c27aefce1d171f99c2b829f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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.18.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b91cdcffeab5f498de44905a373e47e345da8f6c4f40fc969421548c4e7a5219
MD5 249652b6fe3b19b62aa5cb2f645f0d93
BLAKE2b-256 0d2f95ca9ef9285cc6793b3e041efca6c5a194ca6731b0af732631ee074a67b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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.18.0-cp310-abi3-manylinux_2_28_s390x.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_s390x.whl
Algorithm Hash digest
SHA256 567ace3b0d8ac709dc4ad4ce164472f5f59508739355221480170327a6736777
MD5 dc2d1bc20cf971c22c5ddeed25cdf8a0
BLAKE2b-256 4db0005383bd7dc110b06ca731bd2115482f3a8c6389e0c8fe1f7f259380c4c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_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.18.0-cp310-abi3-manylinux_2_28_ppc64le.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 bcd15f7a637ca0654f329ed42a6db0cf7eac15ed89e0b32cb9d16b1b21937979
MD5 f21320f96b472be9e73c85738f8a2988
BLAKE2b-256 f2a496492d7af2ddcd15368f80329e3514060b122f306c4406fac98c08a97865

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_ppc64le.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.18.0-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 91b37c5bb54e233e16c4f47383385f17be03e6a344821c2f6a39a0aebee54538
MD5 9e3a874c210864dffc2e7d296b6a01d2
BLAKE2b-256 e1818ac568efe0289b0ecd826cd697c3581b6a25e134145926cbfef762656167

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-abi3-manylinux_2_28_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.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7e0c626f76bc71d414a02502be7ec0ac2dd6eca369886bc66a2650607f2d9de6
MD5 f2163ecbd1ed79fb9be326c1198234b8
BLAKE2b-256 226869198f41f7f9c39fb5b2e561bf41d4cbd117fa5dfdf4631d8ba28e5ff69b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_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.18.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fce5218ebfb8d8f5313def1f15aad8d3c3c2bbe03e33805dff8cf8bb70370a1
MD5 c5f2ae5b9e938eb6b0bf6c77395d0a3f
BLAKE2b-256 024e09152f4422204f020346a8a2b0e2f05f12d8cc60eeeee99b24f649985514

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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.18.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.18.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7440ba70b87bd16811d92e57d76108840dbdd89aa2fc55e4d324fa2fb6b7f9c9
MD5 29c2a0b34580937bb2e7b05c2aca3b00
BLAKE2b-256 2a7018b310752b0652d4a755b46853268c00c33401101a47f87697ad25966453

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.18.0-cp310-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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page