def eliminate(g, eqs, eq): rowp = [eq] remaining_eqs = sorted(n for n in g if n in eqs and n != eq) heap = PriorityQueue() heap.populate((r, len(g[r])) for r in remaining_eqs) elimination_step(g, heap, eq) while heap: eq, nzeros = heap.peekitem() if nzeros > 1: break heap.popitem() rowp.append(eq) elimination_step(g, heap, eq) return rowp, heap
def eliminate(g, remaining_eqs, eq): rowp = [ eq ] remaining_eqs.remove(eq) heap = PriorityQueue() heap.populate((r, len(g[r])) for r in sorted(remaining_eqs)) elimination_step(g, heap, eq) while heap: eq, nzeros = heap.peekitem() if nzeros > 1: break remaining_eqs.remove(eq) heap.popitem() rowp.append(eq) elimination_step(g, heap, eq) return rowp, heap