From 45da4be0e93d2b33335bdc3d99b21d2f656d2c7c Mon Sep 17 00:00:00 2001 From: Kevin Hartman Date: Tue, 27 Feb 2024 21:13:23 -0500 Subject: [PATCH] Reorder and tweak README.md sections (#1120) * Reorder README.md sections - Moves project history toward the bottom of the page to make it clearer that Rustworkx is freestanding and has utility beyond just Qiskit. - Moves usage upwards, since this is often how new potential users will evaluate how well the library will suit their needs. * Tweak usage text. * More tweaking. * Move description and status around. * Shrink Status header. * A few more minor tweaks. * Improve README.md --------- Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> --- README.md | 103 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index b406e312a..4be818d64 100644 --- a/README.md +++ b/README.md @@ -14,26 +14,37 @@ - You can see the full rendered docs at: -rustworkx is a general purpose graph library for Python written in Rust to -take advantage of the performance and safety that Rust provides. It is -designed to provide a high performance general purpose graph library for -any Python application. +A high-performance, general-purpose graph library for Python, written in Rust. -## Project history +## Usage -Rustworkx was originally called retworkx and was created initially to be -a replacement for [Qiskit](https://www.ibm.com/quantum/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](https://github.com/Qiskit/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. +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.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 +rustworkx is published on [PyPI](https://pypi.org/project/rustworkx/) 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: @@ -41,7 +52,7 @@ installing is as simple as running: pip install rustworkx ``` -This will install a precompiled version of rustworkx into your python +This will install a precompiled version of rustworkx into your Python environment. ### Installing on a platform without precompiled binaries @@ -63,7 +74,8 @@ 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 +> [!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 recieve an error about `setuptools-rust` not being found you should upgrade pip with @@ -88,29 +100,20 @@ 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. -## Using rustworkx - -Once you have rustworkx installed you can use it by importing rustworkx. -All the functions and graph classes are off the root of the package. -For example, calculating the shortest path between A and C would be: - -```python3 -import rustworkx - -graph = rustworkx.PyGraph() +## Authors and Citation -# 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") +rustworkx is the work of [many people](https://github.com/Qiskit/rustworkx/graphs/contributors) who contribute +to the project at different levels. If you use rustworkx in your research, please cite our +[paper](https://doi.org/10.21105/joss.03968) as per the included [BibTeX file](CITATION.bib). -# 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)]) +## Community -# Returns the path A -> B -> C -rustworkx.dijkstra_shortest_paths(graph, a, c, weight_fn=float) -``` +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](https://qiskit.slack.com/messages/rustworkx/). You can join the +Qiskit Slack workspace [here](http://ibm.co/joinqiskitslack). Additionally, +there is an IRC channel `#rustworkx` on the [OFTC IRC network](https://www.oftc.net/) ## Building from source @@ -160,22 +163,20 @@ 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. -It's worth noting that `pip install -e` does not work, as it will link the python +> [!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`. -## Authors and Citation - -rustworkx is the work of [many people](https://github.com/Qiskit/rustworkx/graphs/contributors) who contribute -to the project at different levels. If you use rustworkx in your research, please cite our -[paper](https://doi.org/10.21105/joss.03968) as per the included [BibTeX file](CITATION.bib). - -## Community +## Project history -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](https://qiskit.slack.com/messages/rustworkx/). You can join the -Qiskit Slack workspace [here](http://ibm.co/joinqiskitslack). Additionally, -there is an IRC channel `#rustworkx` on the [OFTC IRC network](https://www.oftc.net/) +Rustworkx was originally called retworkx and was created initially to be +a replacement for [Qiskit](https://www.ibm.com/quantum/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](https://github.com/Qiskit/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.