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?
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
def __init__(self, name=None): Node.__init__(self) self.name = name
def __init__(self, fun, bb, stmt): Node.__init__(self) self.fun = fun self.bb = bb self.stmt = stmt # can be None for empty BBs
def __init__(self, callstring, innernode): Node.__init__(self) self.callstring = callstring self.innernode = innernode
def __init__(self, innernode, stmtg): Node.__init__(self) self.innernode = innernode self.stmtg = stmtg