.. image:: https://img.shields.io/pypi/v/dwave-networkx.svg :target: https://pypi.org/project/dwave-networkx

.. image:: https://readthedocs.com/projects/d-wave-systems-dwave-networkx/badge/?version=latest :target: https://docs.ocean.dwavesys.com/projects/dwave-networkx/en/latest/?badge=latest

.. image:: https://codecov.io/gh/dwavesystems/dwave-networkx/branch/main/graph/badge.svg :target: https://codecov.io/gh/dwavesystems/dwave-networkx

.. image:: https://circleci.com/gh/dwavesystems/dwave-networkx.svg?style=svg :target: https://circleci.com/gh/dwavesystems/dwave-networkx

.. inclusion-marker-do-not-remove

.. index-start-marker

D-Wave NetworkX is an extension of `NetworkX <https://networkx.org>`

_\ ---a
Python language package for exploration and analysis of networks and network
algorithms---for users of D-Wave Systems. It provides tools for working with
Chimera graphs and implementations of graph-theory algorithms on the D-Wave
system and other binary quadratic model samplers.

The example below generates a graph for a Chimera unit cell (eight nodes in a 4-by-2 bipartite architecture).

.. code: python

import dwave_networkx as dnx graph = dnx.chimera_graph(1, 1, 4)

See the documentation for more examples.

.. index-end-marker

.. installation-start-marker

**Installation from PyPi:**

.. code-block:: bash

pip install dwave_networkx

**Installation from source:**

.. code-block:: bash

pip install -r requirements.txt python setup.py install

.. installation-end-marker

Released under the Apache License 2.0.

Ocean's `contributing guide <https://docs.ocean.dwavesys.com/en/stable/contributing.html>`

_
has guidelines for contributing to Ocean packages.

The `networkx`

dependency has been pinned at 2.4 for quite a while, which is quite outdated (currently v2.8.3). The Python support window is sliding, and `networkx2.4`

officially supports py3.5 through py3.8; `networkx2.8.3`

supports py3.8 through py3.10. The NetworkX deprecation policy is that breaking changes can be made over the course of two minor releases, so maintaining this pinned version may be accumulating a backlog of unnoticed deprecations. And, of course, we're missing out on performance improvements and bugfixes.

Updating this pin will require some coordination between `dwave-networkx`

, `minorminer`

, and `dimod`

; I'm sure that this list is incomplete. While there's no immediate need, it would be good to do this sooner rather than later.

**Description**
Readme for dwave-networkx needs updating for other topologies (it only mentions Chimera)

**To Reproduce**
Go to https://docs.ocean.dwavesys.com/en/stable/docs_dnx/sdk_index.html
or readme of this repo

**Expected behavior**
Should also mention Pegasus and Chimera in this sentence: "It provides tools for working with Chimera graphs and implementations of graph-theory algorithms on the D-Wave system and other binary quadratic model samplers."

**Description**
The `draw_chimera`

function takes a NetworkX graph as input. The docstring says "Should be a Chimera graph or a subgraph of a Chimera graph" which can mean either that its edges must be a Chimera lattice subset or that the NetworkX graph must be generated by `chimera_graph`

, it's unclear which is the intention.

Assuming the former, if the NX graph is missing **some** `chimera_index`

attributes, the function returns the obscure `NetworkXError: Found infinite path length because the graph is not connected`

error because `draw_chimera`

tries to calculate the graph's diameter in https://github.com/dwavesystems/dwave-networkx/blob/a4a1eb6176399f6e2aaac8bf9b1b84815320a52d/dwave_networkx/generators/chimera.py#L272

**To Reproduce**

```

G = nx.Graph() G.add_nodes_from([0, 3, 4, 7]) G.add_edges_from([(0, 4), (0, 5), (5, 13)]) dnx.draw_chimera(G, with_labels=True) ```

If I either add the `chimera_index`

to nodes in the two-tile NX graph or stick to the nodes of a single tile (due to https://github.com/dwavesystems/dwave-networkx/blob/a4a1eb6176399f6e2aaac8bf9b1b84815320a52d/dwave_networkx/generators/chimera.py#L288), the function works fine.

**Expected behavior**
1. Clarify if `draw_chimera`

should accept any NX graph that is a subgraph of a Chimera lattice
2. If yes, either require that nodes have `chimera_index`

or add them without an error for more than two unit cells
3. If no, specify in the docstring that the NX graph must be produced by `chimera_graph`

**Environment:**
- OS: WIN
- Python version: 3.7.0

Normalizes node sizes across the board Makes yield plots easier to read Adds qubit-line plots

~needs a little more documentation~

See https://github.com/dwavesystems/minorminer/pull/190#discussion_r741948893.

Hello!

I want to use dwave-networkx with `networkx.DiGraph`

s.
Specifically, I'm trying to pass a `networkx.DiGraph`

to `dwave_networkx.traveling_salesperson`

but it does not seem to work. My DiGraph is complete and I believe does meet other requirements.

Is there already support for DiGraph? If not, I propose it be added.

Thanks!

- Add support for torus QPU graph variations. See https://github.com/dwavesystems/dwave-networkx/pull/225.

- Bug fix/documentation See https://github.com/dwavesystems/dwave-networkx/pull/223.

- No longer depend on
`dwave-preprocessing`

- Support
`dimod>=0.10.8,<0.13.0`

- Fix reliance on Matplotlib's
`DivergingNorm`

. See https://github.com/dwavesystems/dwave-networkx/issues/192 - Add missing decorator to
`weighted_maximum_cut()`

- Drop support for Python 3.6

- Add
`networkx.DiGraph`

support to`traveling_salesperson_qubo()`

. See https://github.com/dwavesystems/dwave-networkx/pull/205. - No longer directly depend on the
`decorators`

package. See https://github.com/dwavesystems/dwave-networkx/pull/213. - Add graph relabeling and sub-lattice mappings. See https://github.com/dwavesystems/dwave-networkx/pull/211.
- Add
`partition()`

and`graph_partition_cqm()`

. See https://github.com/dwavesystems/dwave-networkx/pull/216.

`cmap`

keyword argument can now be correctly supplied to`draw_embedding()`

. See https://github.com/dwavesystems/dwave-networkx/pull/207.

- Add
`zephyr_elimination_order()`

function - Add
`coordinates`

keyword argument to`chimera_elimination_order()`

- Add
`zephyr_coordinates()`

function - Add
`zephyr_layout()`

,`draw_zephyr()`

,`draw_zephyr_embedding()`

, and`draw_zephyr_yield()`

functions - Add
`zephyr_graph()`

and`zephyr_coordinates()`

functions

- Support dimod 0.10

- Fix broken documentation links

- Drop support for python 3.4 and 3.5

- Rearranged requirements files to follow Ocean style

D-Wave's Ocean software and other open-source projects

GitHub Repository Homepage