# Path: dom.py
# def compute_idom(g):
#     for n, info in g.nodes_props():
#         info["idom"] = None
# 
#     entry = g.entry()
#     g[entry]["idom"] = entry
#     changed = True
#     while changed:
#         changed = False
#         it = iter(g.iter_rev_postorder())
#         # Skip root
#         next(it)
#         for n in it:
#             preds_rpo = sorted([(-g[p]["postno"], p) for p in g.pred(n)])
#             new_idom = preds_rpo[0][1]
#             for _, p in preds_rpo[1:]:
#                 if g[p]["idom"] is not None:
#                     new_idom = intersect(g, p, new_idom)
#             if g[n]["idom"] != new_idom:
#                 g[n]["idom"] = new_idom
#                 changed = True
# 
#     g[entry]["idom"] = None
# 
# Path: utils.py
# def make_set(v):
#     "Make set if not already."
#     if isinstance(v, set):
#         return v
#     return {v}


from dom import compute_idom
from utils import make_set
import dot
        g.remove_node(node)
        dot.debug_dot(g)
        return True
    print("t2: no", node)
    return False


def reduce_graph(g):
    changed = True
    while changed:
        print("!iter")
        changed = False
        for node in list(g.nodes()):
            # Might have been deleted by previous iteration
            if node in g:
                changed |= t1_transform(g, node)
                changed |= t2_transform(g, node)


def recursive_relation(g, n, in_prop, out_prop, is_reflexive=False):
    "Helper function to compute relation closures, don't use directly."
    if out_prop in g[n]:
        return g[n][out_prop]
    if in_prop not in g[n]:
        return

    val = g[n][in_prop]
    if val is None:
        val = set()
    else:

# Path: dom.py
# def compute_idom(g):
#     for n, info in g.nodes_props():
#         info["idom"] = None
# 
#     entry = g.entry()
#     g[entry]["idom"] = entry
#     changed = True
#     while changed:
#         changed = False
#         it = iter(g.iter_rev_postorder())
#         # Skip root
#         next(it)
#         for n in it:
#             preds_rpo = sorted([(-g[p]["postno"], p) for p in g.pred(n)])
#             new_idom = preds_rpo[0][1]
#             for _, p in preds_rpo[1:]:
#                 if g[p]["idom"] is not None:
#                     new_idom = intersect(g, p, new_idom)
#             if g[n]["idom"] != new_idom:
#                 g[n]["idom"] = new_idom
#                 changed = True
# 
#     g[entry]["idom"] = None
# 
# Path: utils.py
# def make_set(v):
#     "Make set if not already."
#     if isinstance(v, set):
#         return v
#     return {v}


# Path: xform_graph.py
from dom import compute_idom
from utils import make_set
import dot

        g.remove_node(node)
        dot.debug_dot(g)
        return True
    print("t2: no", node)
    return False


def reduce_graph(g):
    changed = True
    while changed:
        print("!iter")
        changed = False
        for node in list(g.nodes()):
            # Might have been deleted by previous iteration
            if node in g:
                changed |= t1_transform(g, node)
                changed |= t2_transform(g, node)


def recursive_relation(g, n, in_prop, out_prop, is_reflexive=False):
    "Helper function to compute relation closures, don't use directly."
    if out_prop in g[n]:
        return g[n][out_prop]
    if in_prop not in g[n]:
        return

    val = g[n][in_prop]
    if val is None:
        val = set()
    else:

        val = make_set(val)