本文整理汇总了Python中graph.Vertex._make_test_vertex方法的典型用法代码示例。如果您正苦于以下问题:Python Vertex._make_test_vertex方法的具体用法?Python Vertex._make_test_vertex怎么用?Python Vertex._make_test_vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph.Vertex
的用法示例。
在下文中一共展示了Vertex._make_test_vertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_valid_with_weights
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_valid_with_weights():
name1 = Vertex._make_test_vertex()
name2 = Vertex._make_test_vertex()
s = StringIO("2\n{0}\n{1}\n{0}|{1}|5\n{1}|{0}|2".format(name1, name2))
g = graph_from_file(s)
assert g.size() == 2
assert g.is_connected()
示例2: test_has_cycle_two_vertices_linked
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_has_cycle_two_vertices_linked():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(a))
g = Graph([a, b])
assert g.has_cycle()
示例3: test_top_sort_cycle
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_top_sort_cycle():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(a))
g = Graph([a, b])
assert_raises(ValueError, g.top_sort)
示例4: test_extra_pipes
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_extra_pipes():
name1 = Vertex._make_test_vertex()
name2 = Vertex._make_test_vertex()
s = StringIO("2\n{0}\n{1}\n{0}|{1}|5|2\n{1}|{0}|2|5".format(name1, name2))
g = graph_from_file(s)
assert g.size() == 2
assert g.is_connected()
示例5: test_is_connected_two_doubly_connected
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_is_connected_two_doubly_connected():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(a))
g = Graph([a, b])
assert g.is_connected()
示例6: test_no_edges
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_no_edges():
name1 = Vertex._make_test_vertex()
name2 = Vertex._make_test_vertex()
s = StringIO("2\n{}\n{}".format(name1, name2))
g = graph_from_file(s)
assert g.size() == 2
assert not g.is_connected()
示例7: test_top_sort_chain
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_top_sort_chain():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
c = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(c))
g = Graph([a, b, c])
assert g.top_sort() == [a, b, c]
示例8: test_find_path_ignores_weights
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_find_path_ignores_weights():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b, 1))
c = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(c, 100))
b.add_edge(Edge(c, 1))
assert find_path(a, c) == [a, c]
示例9: test_vertex_valid_edges
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_vertex_valid_edges():
"""Test Vertex creation with a list of already-existing Edges."""
b = Vertex(Vertex._make_test_vertex())
c = Vertex(Vertex._make_test_vertex())
d = Edge(b)
e = Edge(c)
a = Vertex(Vertex._make_test_vertex(), [d, e])
assert a.edges == [d, e]
示例10: test_has_cycle_indirect
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_has_cycle_indirect():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
c = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(c))
c.add_edge(Edge(a))
g = Graph([a, b, c])
assert g.has_cycle()
示例11: test_is_connected_three_vert_two_connections
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_is_connected_three_vert_two_connections():
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
c = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(c))
c.add_edge(Edge(a))
g = Graph([a, b, c])
assert g.is_connected()
示例12: test_has_cycle_implicit
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_has_cycle_implicit():
"""A Vertex is accessible to the Graph but not explicitly part of it."""
a = Vertex(Vertex._make_test_vertex())
b = Vertex(Vertex._make_test_vertex())
c = Vertex(Vertex._make_test_vertex())
a.add_edge(Edge(b))
b.add_edge(Edge(c))
c.add_edge(Edge(a))
g = Graph([a, b])
assert g.has_cycle()
示例13: test_edge_weight
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_edge_weight():
a = Vertex(Vertex._make_test_vertex())
b = Edge(a, 10)
assert b.weight == 10
示例14: test_vertex_repr
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_vertex_repr():
s = Vertex._make_test_vertex()
a = Vertex(s)
assert a.__repr__() == "Vertex: {}".format(s)
示例15: test_make_test_vertex
# 需要导入模块: from graph import Vertex [as 别名]
# 或者: from graph.Vertex import _make_test_vertex [as 别名]
def test_make_test_vertex():
s = Vertex._make_test_vertex()
a = Vertex(s)
assert a.name == s