Commit 587e51d5 authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

Add guidedSubdivisionIterator()

parent 5beba525
......@@ -163,6 +163,40 @@ def subdivisionIterator(G, edges = None):
yield L
def guidedSubdivisionIterator(G, edges = None, guide = lambda H: (True, None)):
class DeadEnd(Exception):
pass
if edges is None:
edges = G.edges()
def impl(G, edges):
if len(edges) == 0:
cont, val = guide(G)
if not cont:
raise DeadEnd()
yield val
return
for i in range(0, 3):
H = G.copy()
H.subdivide_edge(edges[0], i)
try:
for L in impl(H, edges[1:]):
yield L
except DeadEnd:
if i == 0:
raise
else:
break
try:
for L in impl(G, edges):
yield L
except DeadEnd:
pass
def generateSubdivisions(file, G, edges = None,
function = lambda H: H.graph6_string(),
parallel = 0, chunksize = 1, in_flight = None):
......
Supports Markdown
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