本文整理汇总了Python中networkx.is_simple_path函数的典型用法代码示例。如果您正苦于以下问题:Python is_simple_path函数的具体用法?Python is_simple_path怎么用?Python is_simple_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_simple_path函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_trivial_nonpath
def test_trivial_nonpath(self):
"""Tests that a list whose sole element is an object not in the
graph is not considered a simple path.
"""
G = nx.trivial_graph()
assert_false(nx.is_simple_path(G, ['not a node']))
示例2: test_trivial_path
def test_trivial_path(self):
"""Tests that the trivial path, a path of length one, is
considered a simple path in a graph.
"""
G = nx.trivial_graph()
assert_true(nx.is_simple_path(G, [0]))
示例3: test_empty_list
def test_empty_list(self):
"""Tests that the empty list is not a valid path, since there
should be a one-to-one correspondence between paths as lists of
nodes and paths as lists of edges.
"""
G = nx.trivial_graph()
assert_false(nx.is_simple_path(G, []))
示例4: test_multidigraph
def test_multidigraph(self):
G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 0), (1, 0)])
assert_true(nx.is_simple_path(G, [0, 1]))
示例5: test_directed_cycle
def test_directed_cycle(self):
G = nx.DiGraph([(0, 1), (1, 2), (2, 0)])
assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
示例6: test_directed_non_path
def test_directed_non_path(self):
G = nx.DiGraph([(0, 1), (1, 2)])
assert_false(nx.is_simple_path(G, [2, 1, 0]))
示例7: test_directed_path
def test_directed_path(self):
G = nx.DiGraph([(0, 1), (1, 2)])
assert_true(nx.is_simple_path(G, [0, 1, 2]))
示例8: test_missing_node
def test_missing_node(self):
G = nx.path_graph(2)
assert_false(nx.is_simple_path(G, [0, 2]))
示例9: test_cycle
def test_cycle(self):
G = nx.cycle_graph(3)
assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
示例10: test_non_simple_path
def test_non_simple_path(self):
G = nx.path_graph(2)
assert_false(nx.is_simple_path(G, [0, 1, 0]))
示例11: test_simple_path
def test_simple_path(self):
G = nx.path_graph(2)
assert_true(nx.is_simple_path(G, [0, 1]))