Skip to main content

A High-Performance Graph Library for Python

Project description

rustworkx

License Build Status Build Status Coverage Status Minimum rustc 1.79 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.79 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>=1.9 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 -U 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.

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 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 set SETUPTOOLS_RUST_CARGO_PROFILE="dev" as an environment variable to build and install rustworkx in develop mode. 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.17.1.tar.gz (399.4 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.17.1-cp39-abi3-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

rustworkx-0.17.1-cp39-abi3-win32.whl (1.9 MB view details)

Uploaded CPython 3.9+Windows x86

rustworkx-0.17.1-cp39-abi3-musllinux_1_2_x86_64.whl (2.3 MB view details)

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

rustworkx-0.17.1-cp39-abi3-musllinux_1_2_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

rustworkx-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

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

rustworkx-0.17.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

rustworkx-0.17.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

rustworkx-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

rustworkx-0.17.1-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.3 MB view details)

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

rustworkx-0.17.1-cp39-abi3-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rustworkx-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustworkx-0.17.1.tar.gz
Algorithm Hash digest
SHA256 59ea01b4e603daffa4e8827316c1641eef18ae9032f0b1b14aa0181687e3108e
MD5 5415dd7bbc4b2ecdee6a5a89502c6ba4
BLAKE2b-256 e7b066d96f02120f79eeed86b5c5be04029b6821155f31ed4907a4e9f1460671

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1.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.17.1-cp39-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d0a48fb62adabd549f9f02927c3a159b51bf654c7388a12fc16d45452d5703ea
MD5 e5139d172e8f98c69ac1e663ba79628a
BLAKE2b-256 a9eccee878c1879b91ab8dc7d564535d011307839a2fea79d2a650413edf53be

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-win32.whl.

File metadata

  • Download URL: rustworkx-0.17.1-cp39-abi3-win32.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 5dbc567833ff0a8ad4580a4fe4bde92c186d36b4c45fca755fb1792e4fafe9b5
MD5 998bae4ce472312fbb9bb52a5201280e
BLAKE2b-256 303da49ab633e99fca4ccbb9c9f4bd41904186c175ebc25c530435529f71c480

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 48784a673cf8d04f3cd246fa6b53fd1ccc4d83304503463bd561c153517bccc1
MD5 c7d46af5ebd510015328825cfa27f60d
BLAKE2b-256 4fefc9199e4b6336ee5a9f1979c11b5779c5cf9ab6f8386e0b9a96c8ffba7009

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 c10d25e9f0e87d6a273d1ea390b636b4fb3fede2094bf0cb3fe565d696a91b48
MD5 a7a18b3d41b32c6732ccbdb9f9db83af
BLAKE2b-256 cc2d30a941a21b81e9db50c4c3ef8a64c5ee1c8eea3a90506ca0326ce39d021f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 246cc252053f89e36209535b9c58755960197e6ae08d48d3973760141c62ac95
MD5 dfd0d3e85657e9345745b5762ced1db7
BLAKE2b-256 395b281bb21d091ab4e36cf377088366d55d0875fa2347b3189c580ec62b44c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 65cba97fa95470239e2d65eb4db1613f78e4396af9f790ff771b0e5476bfd887
MD5 ab29c8d61bc4bb450009d0f1265c55aa
BLAKE2b-256 204b54be84b3b41a19caf0718a2b6bb280dde98c8626c809c969f16aad17458f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 42170075d8a7319e89ff63062c2f1d1116ced37b6f044f3bf36d10b60a107aa4
MD5 f61eff2d2720e1577c00d63ee64da7d8
BLAKE2b-256 d922713b900d320d06ce8677e71bba0ec5df0037f1d83270bff5db3b271c10d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_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.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c7e82c46a92fb0fd478b7372e15ca524c287485fdecaed37b8bb68f4df2720f2
MD5 af3fe2ee50ac9d59c20b8a12a8d4e9f1
BLAKE2b-256 d740ec8b3b8b0f8c0b768690c454b8dcc2781b4f2c767f9f1215539c7909e35b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5b809e0aa2927c68574b196f993233e269980918101b0dd235289c4f3ddb2115
MD5 48cf656de4b004b4cdf27d9d0057885c
BLAKE2b-256 cdeac17fb9428c8f0dcc605596f9561627a5b9ef629d356204ee5088cfcf52c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ef8e327dadf6500edd76fedb83f6d888b9266c58bcdbffd5a40c33835c9dd26
MD5 cd8d7a4971cddc879661d1846ed59b0c
BLAKE2b-256 23ae7b6bbae5e0487ee42072dc6a46edf5db9731a0701ed648db22121fb7490c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustworkx-0.17.1-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.17.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustworkx-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c08fb8db041db052da404839b064ebfb47dcce04ba9a3e2eb79d0c65ab011da4
MD5 ab2b3e0b17cd34a938a49ba96fcfdf95
BLAKE2b-256 20248972ed631fa05fdec05a7bb7f1fc0f8e78ee761ab37e8a93d1ed396ba060

See more details on using hashes here.

Provenance

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