本文整理汇总了Python中testlib.new_digraph函数的典型用法代码示例。如果您正苦于以下问题:Python new_digraph函数的具体用法?Python new_digraph怎么用?Python new_digraph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了new_digraph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_digraph
def test_add_digraph(self):
gr1 = testlib.new_digraph()
gr2 = testlib.new_digraph()
gr1.add_graph(gr2)
for each in gr2.nodes():
self.assertTrue(each in gr1)
for each in gr2.edges():
self.assertTrue(each in gr1.edges())
示例2: test_add_empty_digraph
def test_add_empty_digraph(self):
gr1 = testlib.new_digraph()
gr1c = copy(gr1)
gr2 = digraph()
gr1.add_graph(gr2)
self.assertTrue(gr1.nodes() == gr1c.nodes())
self.assertTrue(gr1.edges() == gr1c.edges())
示例3: test_reverse_digraph
def test_reverse_digraph(self):
gr = testlib.new_digraph()
rev = gr.reverse()
for (u, v) in gr.edges():
self.assertTrue((v, u) in rev.edges())
for (u, v) in rev.edges():
self.assertTrue((v, u) in gr.edges())
示例4: test_invert_digraph
def test_invert_digraph(self):
gr = testlib.new_digraph()
inv = gr.inverse()
for each in gr.edges():
self.assertTrue(each not in inv.edges())
for each in inv.edges():
self.assertTrue(each not in gr.edges())
示例5: test_shortest_path_on_digraph
def test_shortest_path_on_digraph(self):
# Test stub: not checking for correctness yet
gr = testlib.new_digraph(wt_range=(1,10))
st, dist = shortest_path(gr, 0)
for each in gr:
if (each in dist):
assert bf_path(gr, 0, each, dist[each])
示例6: test_dot_xml_digraph
def test_dot_xml_digraph(self):
gr = testlib.new_digraph()
dotstr = markup.write(gr)
gr1 = markup.read(dotstr)
dotstr = markup.write(gr1)
gr2 = markup.read(dotstr)
graph_equality(gr1, gr2)
示例7: test_dot_for_digraph
def test_dot_for_digraph(self):
gr = testlib.new_digraph()
dotstr = dot.write(gr)
gr1 = dot.read(dotstr)
dotstr = dot.write(gr1)
gr2 = dot.read(dotstr)
graph_equality(gr1, gr2)
示例8: test_remove_node
def test_remove_node(self):
gr = testlib.new_digraph()
gr.del_node(0)
self.assertTrue(0 not in gr)
for each, other in gr.edges():
self.assertTrue(each in gr)
self.assertTrue(other in gr)
示例9: test_bfs_in_digraph
def test_bfs_in_digraph(self):
gr = testlib.new_digraph()
st, lo = breadth_first_search(gr)
for each in gr:
if (st[each] != None):
assert lo.index(each) > lo.index(st[each])
for node in st:
assert gr.has_edge((st[node], node)) or st[node] == None
示例10: test_bfs_in_digraph
def test_bfs_in_digraph(self):
gr = testlib.new_digraph()
gr.add_node('find-me')
gr.add_edge((0, 'find-me'))
st, lo = breadth_first_search(gr, root=0, filter=find('find-me'))
assert st['find-me'] == 0
for each in st:
assert st[each] == None or st[each] == 0 or st[st[each]] == 0
示例11: test_dfs_in_digraph
def test_dfs_in_digraph(self):
gr = testlib.new_digraph()
st, pre, post = depth_first_search(gr)
for each in gr:
if (st[each] != None):
assert pre.index(each) > pre.index(st[each])
assert post.index(each) < post.index(st[each])
for node in st:
assert gr.has_edge((st[node], node)) or st[node] == None
示例12: test_dfs_in_digraph
def test_dfs_in_digraph(self):
gr = testlib.new_digraph()
gr.add_node('find-me')
gr.add_node('dont-find-me')
gr.add_edge((0, 'find-me'))
gr.add_edge(('find-me','dont-find-me'))
st, pre, post = depth_first_search(gr, root=0, filter=find('find-me'))
assert st['find-me'] == 0
assert 'dont-find-me' not in st
示例13: test_xml_digraph
def test_xml_digraph(self):
gr = testlib.new_digraph()
dotstr = markup.write(gr)
gr1 = markup.read(dotstr)
dotstr = markup.write(gr1)
gr2 = markup.read(dotstr)
graph_equality(gr1, gr2)
assert len(gr.nodes()) == len(gr1.nodes())
assert len(gr.edges()) == len(gr1.edges())
示例14: test_dot_for_digraph
def test_dot_for_digraph(self):
gr = testlib.new_digraph()
dotstr = dot.write(gr)
gr1 = dot.read(dotstr)
dotstr = dot.write(gr1)
gr2 = dot.read(dotstr)
graph_equality(gr1, gr2)
assert len(gr.nodes()) == len(gr1.nodes())
assert len(gr.edges()) == len(gr1.edges())
示例15: test_output_names_in_dot
def test_output_names_in_dot(self):
gr1 = testlib.new_graph()
gr1.name = "Some name 1"
gr2 = testlib.new_digraph()
gr2.name = "Some name 2"
gr3 = testlib.new_hypergraph()
gr3.name = "Some name 3"
assert "Some name 1" in dot.write(gr1)
assert "Some name 2" in dot.write(gr2)
assert "Some name 3" in dot.write(gr3)