{"id":23646,"library":"dwave-networkx","title":"dwave-networkx","description":"A NetworkX extension providing graphs and algorithms relevant to working with the D-Wave System. Current version: 0.8.18. Release cadence: roughly quarterly.","status":"active","version":"0.8.18","language":"python","source_language":"en","source_url":"https://github.com/dwavesystems/dwave_networkx","tags":["d-wave","quantum-computing","networkx-extension","graph-algorithms"],"install":[{"cmd":"pip install dwave-networkx","lang":"bash","label":"Install dwave-networkx"}],"dependencies":[{"reason":"Core dependency: extends NetworkX with D-Wave specific graph topologies and algorithms.","package":"networkx","optional":false},{"reason":"Required for QUBO formulations and converting to binary quadratic models used by D-Wave systems.","package":"dimod","optional":false}],"imports":[{"note":"dwave_networkx is a top-level package, not a submodule of itself.","wrong":"import dwave_networkx.dwave_networkx as dnx","symbol":"dwave_networkx","correct":"import dwave_networkx as dnx"},{"note":"Correct import for Chimera graph generator.","symbol":"chimera_graph","correct":"from dwave_networkx import chimera_graph"},{"note":"Drawing functions are exposed at the top level.","wrong":"import dwave_networkx.draw.draw_chimera","symbol":"draw_chimera","correct":"from dwave_networkx import draw_chimera"}],"quickstart":{"code":"import networkx as nx\nimport dwave_networkx as dnx\nimport dimod\n\n# Create a Chimera graph (hardware graph)\nG = dnx.chimera_graph(1, 1, 4)\nprint(f\"Nodes: {len(G.nodes)}, Edges: {len(G.edges)}\")\n\n# Example: maximum independent set (QUBO formulation)\nfrom dimod import ExactSolver\n# Solve maximum independent set on a small graph\nH = nx.path_graph(3)\nqubo, offset = dnx.algorithms.independent_set.maximum_independent_set_qubo(H)\nsampler = ExactSolver()\nsampleset = sampler.sample_qubo(qubo)\nsolution = dnx.algorithms.independent_set.maximum_independent_set(H, sampler)\nprint(f\"Maximum independent set: {solution}\")","lang":"python","description":"Basic usage: create a D-Wave graph and solve a problem using dwave-networkx algorithms."},"warnings":[{"fix":"Upgrade Python to 3.9+ or pin dwave-networkx to 0.8.13.","message":"Version 0.8.14 dropped support for Python 3.7 and earlier. If you are using Python 3.7 or below, you must use an older version (<=0.8.13).","severity":"breaking","affected_versions":"<0.8.14"},{"fix":"Run 'pip install dwave-preprocessing' if you use its features directly.","message":"Version 0.8.12 removed dependency on dwave-preprocessing. If your code relied on dwave-preprocessing being installed implicitly, you need to add it explicitly.","severity":"breaking","affected_versions":">=0.8.12"},{"fix":"Monitor NetworkX deprecation warnings. Use `import warnings; warnings.filterwarnings('ignore', category=DeprecationWarning)` if needed.","message":"The dwave-networkx package uses some deprecated NetworkX APIs that may be removed in future NetworkX versions. For example, the use of `nx.MultiGraph` in certain graph constructors may need updating.","severity":"deprecated","affected_versions":"all"},{"fix":"Install Matplotlib: 'pip install matplotlib'.","message":"Drawing functions (e.g., `draw_chimera`, `draw_zephyr`) require Matplotlib to be installed. They will raise an ImportError if Matplotlib is missing.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass a sampler like `dwave.system.DWaveSampler()` to the algorithm.","message":"The `maximum_independent_set` algorithm uses `dimod.ExactSolver()` by default, which is only suitable for very small graphs. For larger graphs, provide a different sampler.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install dwave-networkx' in the correct Python environment.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'dwave_networkx'"},{"fix":"Use 'from dwave_networkx import chimera_graph'.","cause":"Using incorrect import path (e.g., from dwave_networkx.generators import chimera_graph instead of from dwave_networkx import chimera_graph).","error":"ImportError: cannot import name 'chimera_graph'"},{"fix":"Install Matplotlib: 'pip install matplotlib'. If that doesn't work, update dwave-networkx to >=0.8.10.","cause":"Matplotlib is not installed, or using an old version of dwave-networkx before drawing functions were added.","error":"AttributeError: module 'dwave_networkx' has no attribute 'draw_chimera'"},{"fix":"Ensure the input graph matches the topology requirements. Check the documentation for the specific algorithm.","cause":"Using a graph not compatible with the expected topology (e.g., trying to embed a non-bipartite graph into a Chimera structure).","error":"ValueError: The graph is not bipartite?"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}