Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chimera_graph mxn lattice is flattened #190

Open
JoelPasvolsky opened this issue Mar 5, 2021 · 4 comments
Open

chimera_graph mxn lattice is flattened #190

JoelPasvolsky opened this issue Mar 5, 2021 · 4 comments

Comments

@JoelPasvolsky
Copy link
Contributor

Description
I expected that chimera_graph(m) or chimera_graph(m,m) would have be a m-by-m lattice but instead am getting a row of length mxm.

To Reproduce

>>> c4 = dnx.chimera_graph(4)
>>> c4.nodes
NodeView((0, 4, 5, 6, 7, 1, 2, 3, 32, 36, 37, 38, 39, 33, 34, 35, 64, 68, 69, 70, 71, 65, 66, 67, 96, 100, 101, 102, 103, 97, 98, 99, 8, 12, 13, 14, 15, 9, 10, 11, 40, 44, 45, 46, 47, 41, 42, 43, 72, 76, 77, 78, 79, 73, 74, 75, 104, 108, 109, 110, 111, 105, 106, 107, 16, 20, 21, 22, 23, 17, 18, 19, 48, 52, 53, 54, 55, 49, 50, 51, 80, 84, 85, 86, 87, 81, 82, 83, 112, 116, 117, 118, 119, 113, 114, 115, 24, 28, 29, 30, 31, 25, 26, 27, 56, 60, 61, 62, 63, 57, 58, 59, 88, 92, 93, 94, 95, 89, 90, 91, 120, 124, 125, 126, 127, 121, 122, 123))

This gives:

image

Expected behavior
I expected:

image

Environment:

  • OS: WIN10
  • Python version: 3.7.0

Additional context
Add any other context about the problem here.

@boothby
Copy link
Contributor

boothby commented Mar 5, 2021

I think this is a problem with the inspector and not the chimera graph generator.

import dwave_networkx as dnx
from matplotlib import pyplot as plt

c4 = dnx.chimera_graph(4, 4)
plt.figure(figsize=(5,5))
dnx.draw_chimera(c4)
plt.savefig('c4.png')

c4

@JoelPasvolsky
Copy link
Contributor Author

@boothby, the output of dnx.chimera_graph(4) includes node 40, 44, 45, 46, 47, 41, 42, 43. I had expected C4 nodes to be [0, 1 .. 8x4, 8x16, 8x16+1, ... 8x20, 8x20+1, ...]
But I guess that assumes C4 as a subgraph of C16.
Thanks!

@boothby
Copy link
Contributor

boothby commented Mar 5, 2021

You can get that subgraph as follows:

g = dnx.chimera_graph(16)
c4_nodes = [v for v, d in g.nodes(data=True) if all(x < 4 for x in d['chimera_index'][:2])]
c4 = g.subgraph(c4_nodes)

@JoelPasvolsky
Copy link
Contributor Author

Thanks, @boothby, I just changed the first line to g = dnx.chimera_graph(16, node_list=qpu.nodelist, edge_list=qpu.edgelist) to account for available qubits & couplers, and that works perfectly:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants