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

Issue with chimera_layout mistaking single tile for multiple tiles. #91

Open
davage opened this issue Jan 4, 2019 · 2 comments
Open

Comments

@davage
Copy link

davage commented Jan 4, 2019

Description
The chimera_layout function uses the networkx function diameter, which can be > 2 for some configurations of our chimera graphs.

To Reproduce
The example on the demo page is working:
https://docs.ocean.dwavesys.com/projects/dwave-networkx/en/latest/reference/drawing.html
However the following modification will cause an error in which the code mistakes the connected graph for being from two connected tiles:
`import networkx as nx
import dwave_networkx as dnx
import matplotlib.pyplot as plt

H = nx.Graph()
H.add_nodes_from([0, 1, 4, 5, 6, 7])
H.add_edges_from([(0, 4), (0, 5), (0, 6), (0, 7)])
H.add_edges_from([(1, 4)])
pos = dnx.chimera_layout(H)
G = dnx.chimera_graph(1,1,4)
ind = dnx.find_chimera_indices(G)
dnx.draw_chimera(G)
dnx.draw_chimera(H, node_color='b', node_shape='*', style='dashed', edge_color='b', width=3)
dnx.chimera_layout(H, scale=1., center=None, dim=2)
plt.show()`

There are a few similar issues, so it might be a good idea to check a few different cases.
This one draws as if 2 is 1.
H.add_nodes_from([0, 2, 4, 5, 6, 7]) H.add_edges_from([(0, 4), (0, 5), (0, 6), (0, 7)]) H.add_edges_from([(2, 4), (2, 5), (2, 6), (2, 7)])

Expected behavior
Partial chimera graphs should draw correctly.

The first example should draw an extra dashed line from node 1 to node 4.

The second example should produce a chimera graph tile with the 0 node and the 2 node fully connected.

Environment:

  • OS: Windows 10 Pro
  • Python version: 3.7.1

Additional context
This issue showed up from a user trying to run the example in drawing chimera graph functions:
#90

@joseppinilla
Copy link
Contributor

joseppinilla commented Jul 15, 2019

I think this and #90 are non-issues.
I found these while trying to do something similar, i.e. create a chimera graph by adding custom nodes and edges.

But I don't expect it to work in the way that is exemplified here because (1) the H graph isn't created as a chimera_graph to begin with. (2) even if it is, adding nodes would need to be done in a way that modifies the corresponding graph dictionary, or invalidates it.

So... either use the method in my next post, or there needs to be a Chimera graph class (Not the way NetworkX is supposed to be used) or interfaces to incrementally construct Chimera/Pegasus graphs e.g. dnx.add_chimera_nodes_from(H, <nodes>) dnx.add_chimera_edges_from(H, <edges>) dnx.add_pegasus_...

Or... a way to "Chimerify" (?) or "Pegasify" (?) graphs.

@joseppinilla
Copy link
Contributor

The way I would do it right now is:

node_list = [0, 1, 4, 5, 6, 7]
edge_list = [(0, 4), (0, 5), (0, 6), (0, 7), (1, 4)]
H = dnx.chimera_graph(1,1,node_list=node_list,edge_list=edge_list)
...
dnx.draw_chimera(H, node_color='b', node_shape='*', style='dashed', edge_color='b', width=3)

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