{"id":21876,"library":"retworkx","title":"retworkx","description":"A high-performance graph library for Python, written in Rust, providing directed and undirected graph data structures with efficient algorithms. Current version 0.17.1, release cadence irregular.","status":"active","version":"0.17.1","language":"python","source_language":"en","source_url":"https://github.com/Qiskit/retworkx","tags":["graph","rust","performance","DAG","directed","undirected"],"install":[{"cmd":"pip install retworkx","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"Direct import is fine, but idiomatic usage is `import retworkx as rx`","wrong":"from retworkx import PyGraph","symbol":"PyGraph","correct":"import retworkx as rx; g = rx.PyGraph()"},{"note":"Avoid aliasing to avoid confusion with other graph libraries","wrong":"from retworkx import PyDiGraph as DiGraph","symbol":"PyDiGraph","correct":"import retworkx as rx; g = rx.PyDiGraph()"}],"quickstart":{"code":"import retworkx as rx\n\ndag = rx.PyDiGraph()\nnode_a = dag.add_node('A')\nnode_b = dag.add_child(node_a, 'B', None)\nprint(dag.nodes())\nprint(dag.edges())","lang":"python","description":"Create a directed acyclic graph, add nodes and edges, and print them."},"warnings":[{"fix":"Migrate to using PyGraph and PyDiGraph classes. See migration guide at https://qiskit.org/documentation/retworkx/","message":"Version 0.14.0 replaced the original function-based API with the class-based API (PyGraph, PyDiGraph). Code using `from retworkx import *` or older function names will break.","severity":"breaking","affected_versions":"<0.14.0"},{"fix":"Replace `retworkx.digraph()` with `retworkx.PyDiGraph()` and similarly for undirected graphs.","message":"The `digraph` and `graph` constructor functions are deprecated and removed in 0.14.0.","severity":"deprecated","affected_versions":">=0.10.0, <0.14.0"},{"fix":"Assign custom node data or use node indices immediately; do not assume order.","message":"Node indices are integers returned by add_node/add_child; do not rely on them being sequential or stable after deletions.","severity":"gotcha","affected_versions":"all"},{"fix":"Always provide an explicit weight (or None) to avoid unexpected behavior.","message":"Edge weights are optional but must be passed as the third argument to add_child; passing None is acceptable but can lead to type confusion.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install retworkx` in the correct environment (Python >=3.9).","cause":"retworkx not installed or environment not activated","error":"ModuleNotFoundError: No module named 'retworkx'"},{"fix":"Provide a third argument, e.g., `dag.add_child(parent, child, None)`.","cause":"Missing the edge weight argument in add_child","error":"TypeError: add_child() missing 1 required positional argument: 'obj'"},{"fix":"Use `retworkx.PyDiGraph()` instead of `retworkx.digraph()`.","cause":"Using the deprecated function name from old versions (<0.14.0)","error":"AttributeError: module 'retworkx' has no attribute 'digraph'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}