Skip to content

Commit

Permalink
fixed sporadic (1/15th of the time) failure reported in #227 (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
boothby authored Jan 23, 2023
1 parent 72c4d15 commit 756a53a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/test_busclique.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,21 +468,44 @@ def test_regularize_embedding_bug_215(self):

def test_topology_identifier(self):
perfect_id = '38cad89632b234831d58675091f1bc581c96de65d4b2a0c06c0d94a7f97e21a7'
p16 = dnx.pegasus_graph(16)
p16 = dnx.pegasus_graph(16, coordinates=True)
bgc = busclique.busgraph_cache(p16)
self.assertEqual(
bgc.topology_identifier(),
perfect_id,
f'Topology identifier does not match expectation. If busclique.__cache_version changed, this test needs to be updated.'
)

e = random.choice(list(p16.edges))
# see minorminer issue #227 on github -- the busclique algorithm does
# not depend on odd edges and does not include them in its serialization
odd_edges = []
relevant_edges = []
for p, q in p16.edges:
if p[0] == q[0] and p[-1] == q[-1]:
odd_edges.append((p, q))
else:
relevant_edges.append((p, q))

# it's actually possible that we will include those edges in the future
# though -- there are some optimal clique embeddings which utilize odd
# edges -- let's put in an explicit test to remind ourselves to update
# this test under that eventuality
e = random.choice(odd_edges)
p16.remove_edge(*e)
bgc_o = busclique.busgraph_cache(p16)
self.assertEqual(
bgc_o.topology_identifier(),
perfect_id,
f'topology identifier changed after deleting odd edge {e}'
)

e = random.choice(relevant_edges)
p16.remove_edge(*e)
bgc_e = busclique.busgraph_cache(p16)
self.assertNotEqual(
bgc_e.topology_identifier(),
perfect_id,
f'topology identifier did not change after removing edge {e}'
f'topology identifier did not change after removing non-odd edge {e}'
)

p16 = dnx.pegasus_graph(16)
Expand Down

0 comments on commit 756a53a

Please sign in to comment.