rustworkx

rustworkx: A High-Performance Graph Library for Python - Published in JOSS (2022)

https://github.com/qiskit/rustworkx

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: arxiv.org, joss.theoj.org
  • Committers with academic emails
    4 of 89 committers (4.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

dag graph graph-theory python rust

Keywords from Contributors

qiskit physics quantum quantum-computing mesh
Last synced: 4 months ago · JSON representation ·

Repository

A high performance Python graph library implemented in Rust.

Basic Info
  • Host: GitHub
  • Owner: Qiskit
  • License: apache-2.0
  • Language: Rust
  • Default Branch: main
  • Homepage: https://www.rustworkx.org
  • Size: 41.4 MB
Statistics
  • Stars: 1,426
  • Watchers: 14
  • Forks: 191
  • Open Issues: 130
  • Releases: 33
Topics
dag graph graph-theory python rust
Created over 6 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Code of conduct Citation Security Zenodo

README.md

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.

```python3 import rustworkx

Rustworkx's undirected graph type.

graph = rustworkx.PyGraph()

Each time add node is called, it returns a new node index

a = graph.addnode("A") b = graph.addnode("B") c = graph.add_node("C")

addedgesfrom takes tuples of node indices and weights,

and returns edge indices

graph.addedgesfrom([(a, b, 1.5), (a, c, 5.0), (b, c, 2.5)])

Returns the path A -> B -> C

rustworkx.dijkstrashortestpaths(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:

bash 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:

bash 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:

bash 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:

bash pip install .

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

bash 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.

Owner

  • Name: Qiskit
  • Login: Qiskit
  • Kind: organization
  • Email: qiskit@us.ibm.com

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

JOSS Publication

rustworkx: A High-Performance Graph Library for Python
Published
November 01, 2022
Volume 7, Issue 79, Page 3968
Authors
Matthew Treinish ORCID
IBM Quantum, IBM T.J. Watson Research Center, Yorktown Heights, USA \newline
Ivan Carvalho ORCID
University of British Columbia, Kelowna, Canada \newline
Georgios Tsilimigkounakis ORCID
National Technical University of Athens, Athens, Greece \newline
Nahum Sá ORCID
Centro Brasileiro de Pesquisas Físicas, Rio de Janeiro, Brazil
Editor
Vincent Knight ORCID
Tags
graph theory

Citation (CITATION.bib)

@article{Treinish2022, 
  doi = {10.21105/joss.03968}, 
  url = {https://doi.org/10.21105/joss.03968}, 
  year = {2022}, 
  publisher = {The Open Journal}, 
  volume = {7}, 
  number = {79}, 
  pages = {3968}, 
  author = {Matthew Treinish and Ivan Carvalho and Georgios Tsilimigkounakis and Nahum Sá}, 
  title = {rustworkx: A High-Performance Graph Library for Python}, 
  journal = {Journal of Open Source Software}
}

GitHub Events

Total
  • Create event: 145
  • Release event: 1
  • Issues event: 76
  • Watch event: 290
  • Delete event: 135
  • Issue comment event: 520
  • Push event: 204
  • Pull request review comment event: 301
  • Pull request review event: 330
  • Pull request event: 241
  • Fork event: 40
Last Year
  • Create event: 145
  • Release event: 1
  • Issues event: 77
  • Watch event: 290
  • Delete event: 135
  • Issue comment event: 521
  • Push event: 204
  • Pull request review comment event: 301
  • Pull request review event: 330
  • Pull request event: 241
  • Fork event: 40

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,037
  • Total Committers: 89
  • Avg Commits per committer: 11.652
  • Development Distribution Score (DDS): 0.567
Past Year
  • Commits: 143
  • Committers: 25
  • Avg Commits per committer: 5.72
  • Development Distribution Score (DDS): 0.72
Top Committers
Name Email Commits
Matthew Treinish m****h@k****g 449
dependabot[bot] 4****] 218
Ivan Carvalho i****v@s****a 110
georgios-ts 4****s 36
Edwin Navarro e****o@c****t 22
Krishn Parasar 7****2 22
Miroslav Šedivý 6****o 15
Jake Lishman j****n@i****m 12
Nahum Rosa Cruz Sa 4****a 9
Prakhar Bhatnagar 4****0 7
Lauren Capelluto l****o@g****m 7
Eric Arellano 1****o 7
Kevin Hartman k****n@h****n 6
Alexander Ivrii a****i@i****m 6
Etienne Wodey 4****x 5
Simon Lizotte 5****4 4
ZhengYu, Xu z****u@o****m 4
danielleodigie 9****e 4
Raynel Sanchez 8****s 3
Luciano Bello b****l@z****m 3
John Lapeyre j****e 3
Bhaavan Goel c****n@g****m 3
danieleades 3****s 2
derbuihan d****n@g****m 2
ewinston e****n@u****m 2
Yiming Zhang 6****g 2
Salvador de la Puente González s****a@u****m 2
gadial g****l@g****m 2
jpacold j****d@g****m 2
maleicacid 4****4 2
and 59 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 185
  • Total pull requests: 834
  • Average time to close issues: 4 months
  • Average time to close pull requests: 15 days
  • Total issue authors: 95
  • Total pull request authors: 75
  • Average comments per issue: 1.98
  • Average comments per pull request: 2.01
  • Merged pull requests: 665
  • Bot issues: 2
  • Bot pull requests: 280
Past Year
  • Issues: 58
  • Pull requests: 292
  • Average time to close issues: 13 days
  • Average time to close pull requests: 8 days
  • Issue authors: 33
  • Pull request authors: 32
  • Average comments per issue: 1.45
  • Average comments per pull request: 2.23
  • Merged pull requests: 218
  • Bot issues: 0
  • Bot pull requests: 60
Top Authors
Issue Authors
  • IvanIsCoding (30)
  • mtreinish (23)
  • jakelishman (8)
  • barakatzir (8)
  • yurivict (5)
  • LaurentBergeron (4)
  • Paulo-21 (3)
  • jlapeyre (3)
  • enavarro51 (3)
  • thomasaarholt (3)
  • amirebrahimi (3)
  • alexanderivrii (3)
  • kasium (2)
  • rok24 (2)
  • lukepmccombs (2)
Pull Request Authors
  • dependabot[bot] (251)
  • IvanIsCoding (151)
  • mtreinish (106)
  • Krishn1412 (35)
  • eumiro (31)
  • mergify[bot] (29)
  • jakelishman (20)
  • enavarro51 (11)
  • kevinhartman (10)
  • Eric-Arellano (10)
  • airwoodix (10)
  • SILIZ4 (9)
  • zen-xu (8)
  • alexanderivrii (6)
  • jpacold (6)
Top Labels
Issue Labels
bug (46) enhancement (45) good first issue (32) dependencies (8) help wanted (8) rustworkx-core (4) documentation (4) question (3) hard (2) stable-backport-potential (1) Epic (1) automerge (1) on hold (1)
Pull Request Labels
dependencies (264) automerge (237) stable-backport-potential (17) on hold (10) documentation (8) rustworkx-core (8) conflicts (6) Epic (3)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 3,328,425 last-month
    • cargo 602,697 total
  • Total docker downloads: 9,956,588
  • Total dependent packages: 53
    (may contain duplicates)
  • Total dependent repositories: 340
    (may contain duplicates)
  • Total versions: 75
  • Total maintainers: 3
pypi.org: rustworkx

A High-Performance Graph Library for Python

  • Versions: 12
  • Dependent Packages: 36
  • Dependent Repositories: 81
  • Downloads: 3,309,555 Last month
  • Docker Downloads: 9,955,157
Rankings
Downloads: 0.3%
Dependent packages count: 0.5%
Dependent repos count: 1.7%
Average: 1.9%
Docker downloads count: 2.1%
Stargazers count: 2.4%
Forks count: 4.4%
Maintainers (1)
Last synced: 4 months ago
pypi.org: retworkx

A python graph library implemented in Rust

  • Versions: 40
  • Dependent Packages: 16
  • Dependent Repositories: 239
  • Downloads: 18,870 Last month
  • Docker Downloads: 1,431
Rankings
Dependent packages count: 0.6%
Dependent repos count: 1.0%
Downloads: 1.3%
Docker downloads count: 1.8%
Average: 2.0%
Stargazers count: 2.7%
Forks count: 4.5%
Maintainers (1)
Last synced: 4 months ago
crates.io: rustworkx-core

Rust APIs used for rustworkx algorithms

  • Versions: 13
  • Dependent Packages: 0
  • Dependent Repositories: 20
  • Downloads: 602,697 Total
Rankings
Downloads: 4.7%
Dependent repos count: 6.0%
Forks count: 6.6%
Stargazers count: 6.8%
Average: 12.1%
Dependent packages count: 36.1%
Maintainers (1)
Last synced: 4 months ago
spack.io: py-rustworkx

Rustworkx was originally called retworkx and was 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-terra'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.

  • Versions: 10
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 11.2%
Forks count: 12.0%
Average: 20.1%
Dependent packages count: 57.2%
Maintainers (1)
Last synced: 4 months ago

Dependencies

Cargo.lock cargo
  • ahash 0.7.6
  • autocfg 1.1.0
  • bitflags 1.3.2
  • cfg-if 1.0.0
  • crossbeam-channel 0.5.4
  • crossbeam-deque 0.8.1
  • crossbeam-epoch 0.9.8
  • crossbeam-utils 0.8.8
  • either 1.6.1
  • fixedbitset 0.4.1
  • getrandom 0.2.5
  • hashbrown 0.11.2
  • hermit-abi 0.1.19
  • indexmap 1.7.0
  • indoc 1.0.4
  • instant 0.1.12
  • lazy_static 1.4.0
  • libc 0.2.121
  • lock_api 0.4.6
  • matrixmultiply 0.2.4
  • memchr 2.4.1
  • memoffset 0.6.5
  • ndarray 0.13.1
  • num-bigint 0.4.3
  • num-complex 0.2.4
  • num-complex 0.4.1
  • num-integer 0.1.44
  • num-traits 0.2.15
  • num_cpus 1.13.1
  • numpy 0.16.2
  • once_cell 1.10.0
  • parking_lot 0.11.2
  • parking_lot_core 0.8.5
  • petgraph 0.6.2
  • ppv-lite86 0.2.16
  • proc-macro2 1.0.36
  • pyo3 0.16.5
  • pyo3-build-config 0.16.5
  • pyo3-ffi 0.16.5
  • pyo3-macros 0.16.5
  • pyo3-macros-backend 0.16.5
  • quick-xml 0.22.0
  • quote 1.0.16
  • rand 0.8.5
  • rand_chacha 0.3.1
  • rand_core 0.6.3
  • rand_pcg 0.3.1
  • rawpointer 0.2.1
  • rayon 1.5.3
  • rayon-core 1.9.2
  • redox_syscall 0.2.12
  • scopeguard 1.1.0
  • smallvec 1.8.0
  • syn 1.0.89
  • target-lexicon 0.12.3
  • unicode-xid 0.2.2
  • unindent 0.1.8
  • version_check 0.9.4
  • wasi 0.10.2+wasi-snapshot-preview1
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-x86_64-pc-windows-gnu 0.4.0
Cargo.toml cargo
  • ahash 0.7.6
  • fixedbitset 0.4.1
  • hashbrown 0.11
  • indexmap 1.7
  • ndarray ^0.13.1
  • num-bigint 0.4
  • num-complex 0.4
  • num-traits 0.2
  • numpy 0.16.2
  • petgraph 0.6.2
  • pyo3 0.16.5
  • quick-xml 0.22.0
  • rand 0.8
  • rand_pcg 0.3
  • rayon 1.5
  • retworkx-core =0.12.0
docs/source/requirements.txt pypi
  • jupyter-sphinx *
  • m2r2 *
  • matplotlib >=3.4
  • pillow >=4.2.1
  • pydot *
  • qiskit-sphinx-theme >=1.7
  • reno >=3.4.0
  • sphinx >=3.0.0
  • sphinx-reredirects *
  • sphinx_rtd_theme *
setup.py pypi
  • numpy >=1.16.0
.github/workflows/docs_dev.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/docs_release.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/main.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • coverallsapp/github-action master composite
  • dtolnay/rust-toolchain stable composite
  • dtolnay/rust-toolchain master composite
.github/workflows/wheels.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • docker/setup-qemu-action v2 composite
  • dtolnay/rust-toolchain stable composite
  • joerick/cibuildwheel v2.10.1 composite
rustworkx-core/Cargo.toml cargo
pyproject.toml pypi