Esempio n. 1
0
 def test_no_path(self):
     g = Graph()
     a = g.add_node(Node())
     b = g.add_node(Node())
     # no edges between them
     path = g.get_shortest_path(a, b)
     self.assertEqual(path, [])  # FIXME: shouldn't this be None?
Esempio n. 2
0
def add_long_path(g, length):
    """
    Construct a path of the form:
        first -> n0 -> n1 -> .... -> last
    where there are "length" edges
    """
    first = g.add_node(Node())
    last = first
    cur = first
    for i in range(length):
        last = g.add_node(Node())
        g.add_edge(cur, last)
        cur = last
    return first, last
Esempio n. 3
0
 def __init__(self, name=None):
     Node.__init__(self)
     self.name = name
Esempio n. 4
0
 def __init__(self, fun, bb, stmt):
     Node.__init__(self)
     self.fun = fun
     self.bb = bb
     self.stmt = stmt # can be None for empty BBs
Esempio n. 5
0
 def __init__(self, fun, bb, stmt):
     Node.__init__(self)
     self.fun = fun
     self.bb = bb
     self.stmt = stmt  # can be None for empty BBs
Esempio n. 6
0
 def __init__(self, callstring, innernode):
     Node.__init__(self)
     self.callstring = callstring
     self.innernode = innernode
Esempio n. 7
0
 def __init__(self, innernode, stmtg):
     Node.__init__(self)
     self.innernode = innernode
     self.stmtg = stmtg
Esempio n. 8
0
 def __init__(self, innernode, stmtg):
     Node.__init__(self)
     self.innernode = innernode
     self.stmtg = stmtg
Esempio n. 9
0
 def __init__(self, name=None):
     Node.__init__(self)
     self.name = name