Skip to content

edge_list and node_list behave unexpectedly in graph generators #245

@jackraymond

Description

@jackraymond

Description
It is useful to permute node and edge orderings in graph creation for example to randomize the behaviour of otherwise deterministic methods.

  • dwave_networkx graph node ordering doesn't seem to respond to the ordering of the node_list parameter.
  • When the edge_list parameter is provided matching the default, the node_ordering is changed relative to the default.

To Reproduce

T = dnx.pegasus_graph(2)
node_list = list(T.nodes())
node_list.reverse()
T2 = dnx.pegasus_graph(2, node_list=node_list)  # Same graph
print(T2.nodes())  # original ordering, ignores provided ordering.
edge_list = list(T1.edges())
node_list = list(T1.nodes())
T3 = dnx.pegasus_graph(2, node_list=node_list, edge_list=edge_list)
print(T3.nodes())  # Does not match T1.nodes(), which is unexpected.

Expected behavior
node_list should dictate node order, edge_list should dictate edge order.

Environment:

  • OS: [Ubuntu 22.04.3 LTS]
  • Python version: [e.g. 3.12.0]

Additional context
I'll make a pull request to correct this unless a good case can be made not to, don't really want to mess with these core generators unnecessarily.
I want to use in combination with minorminer.subgraph.find_subgraph(S, T) which deterministically searches for a subgraph. Reordering the target (T) nodes allows a more uniform distribution across the processor with respect to some source graph S.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions