Beispiel #1
0
def main():
    with open('example.dot', 'rt') as f:
        root, nodes = dot.parse(f)

    tmp = list(nodes.values())
    n = len(nodes)
    results = []
    for i in range(n):
        A = tmp[i]
        for j in range(i + 1, n):
            B = tmp[j]
            C = lowest_common_ancestor(A, B)

            results.append((A, B, C))

    for A, B, C in results:
        path = f'lca_{A.label}-{B.label}.dot'
        attr = {
            A.label: 'style="filled", color="lightblue"',
            B.label: 'style="filled", color="lightgreen"',
            C.label: 'style="filled", color="hotpink"',
        }

        with open(path, 'wt') as f:
            dot.save(f, nodes, attr)
def test_appel_2ed_p221():
    ig = gen_interf("appel-2ed-p221.ll")
    refg = dot.parse(open(datadir + "appel-2ed-p221.dot"), UngraphEdgeList())
    assert ig == refg, "%s vs %s" % (ig, refg)
Beispiel #3
0
def t(data, exptected=None):
    eq_(parse(tokenize(data)), exptected)
Beispiel #4
0
 def t(self, data, expected=None):
     self.assertEqual(parse(tokenize(data)), expected)
Beispiel #5
0
 def t(self, data, expected=None):
     self.assertEqual(parse(tokenize(data)), expected)
Beispiel #6
0
def t(data, exptected=None):
    eq_(parse(tokenize(data)), exptected)