Skip to content

Commit

Permalink
fixed #215, infinite loop in busclique._regularize_embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
boothby authored Jun 14, 2022
1 parent a156ead commit a19e7f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions minorminer/busclique.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ def _regularize_embedding(g, emb):
emb = {i: list(chain) for i, chain in emb.items()}
remainder = set(g) - set().union(*emb.values())
while progress:
progress = False
matching_graph = nx.Graph()
top_nodes = []
for i, chain in emb.items():
Expand Down Expand Up @@ -1313,6 +1314,7 @@ def mine_clique_embeddings(
emb1 = _regularize_embedding(g, emb)
bgc.insert_clique_embedding(emb1, write_to_disk=False, quality_function=quality_function)

logger.info("writing embedding cache to disk")
bgc.insert_clique_embedding({}, write_to_disk=True)
return bgc

Expand Down
26 changes: 26 additions & 0 deletions tests/test_busclique.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,32 @@ def test_mine_clique_embeddings_smoketest(self):
heuristic_runs=1,
)

def test_regularize_embedding_bug_215(self):
emb = {0: [206], 1: [127, 130, 134, 242, 133], 2: [129], 3: [126], 4: [209], 5: [179, 135, 136]}
missing_nodes = (17, 32, 132, 155, 212, 215, 230, 263, 280)
missing_edges = [
(8, 11), (9, 162), (13, 231), (15, 198), (22, 216), (25, 222),
(26, 264), (27, 195), (31, 222), (31, 225), (34, 219), (34, 198),
(35, 249), (36, 174), (37, 204), (40, 201), (40, 210), (43, 186),
(45, 163), (46, 216), (48, 189), (49, 243), (54, 181), (54, 174),
(56, 256), (57, 177), (58, 232), (59, 253), (59, 262), (61, 223),
(61, 204), (64, 226), (65, 262), (66, 184), (67, 220), (67, 214),
(70, 217), (70, 220), (71, 253), (72, 163), (77, 229), (80, 253),
(81, 181), (82, 83), (82, 214), (84, 175), (86, 250), (88, 220),
(90, 200), (92, 275), (93, 178), (95, 260), (95, 272), (97, 200),
(97, 205), (98, 236), (99, 169), (100, 224), (103, 203), (103, 209),
(105, 185), (105, 197), (108, 182), (109, 218), (112, 200),
(113, 236), (114, 117), (117, 185), (120, 191), (130, 245),
(131, 278), (131, 281), (134, 251), (164, 167), (172, 173),
(180, 183), (187, 188), (194, 197), (198, 199), (216, 217),
(217, 218), (222, 225), (237, 238), (238, 239), (270, 273)
]
p4 = dnx.pegasus_graph(4)
p4.remove_nodes_from(missing_nodes)
p4.remove_edges_from(missing_edges)
busclique._regularize_embedding(p4, emb)


def find_nondeterminism(family, size=4, tries=10):
if family == 'pegasus':
generator = dnx.pegasus_graph
Expand Down

0 comments on commit a19e7f6

Please sign in to comment.