Commit aa4f017b authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

bugfix: remove all the occurences of dominated d-graphs insted of only one

parent 6318e0a5
......@@ -165,6 +165,10 @@ class D2Graph(object):
# Find dominated
for dmer, dg_list in self.index.items():
undominated = list_domination_filter(dg_list)
# if len(undominated) > 1:
# print(dmer)
# print("\n".join([str(x) for x in undominated]))
# print()
# Register dominated
if len(dg_list) != len(undominated):
......@@ -182,11 +186,11 @@ class D2Graph(object):
# Remove dominated in index
removable_dmers = []
for dmer, indexed_list in self.index.items():
for dmer in self.index:
for r_dg in to_remove:
if r_dg in indexed_list:
indexed_list.remove(r_dg)
if len(indexed_list) == 0:
if r_dg in self.index[dmer]:
self.index[dmer] = list(filter(lambda x: x!=r_dg, self.index[dmer]))
if len(self.index[dmer]) == 0:
removable_dmers.append(dmer)
# Remove empty dmers
......
......@@ -46,11 +46,13 @@ class TestD2Graph(unittest.TestCase):
# Test index
awaited_index_size = comb(2*d+1, index_k) + (size - (2*d+1)) * comb(2*d, index_k-1)
print(d, size, index_k, awaited_index_size)
# print(d, size, index_k, awaited_index_size)
if len(d2.index) != awaited_index_size:
dmers = [list(x) for x in d2.index]
dmers = [str(x) for x in dmers if len(x) != len(frozenset(x))]
print("\n".join(dmers))
dmers = [x for x in dmers if len(x) != len(frozenset(x))]
dmers = [str(x) for x in dmers]
# print("\n".join(dmers))
self.assertEquals(awaited_index_size, len(d2.index))
d2_nx = d2.nx_graph
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment