Пример #1
0
    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
0
    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
0
    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
0
 def test_directed_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_true(nx.is_simple_path(G, [0, 1, 2]))
Пример #5
0
 def test_directed_non_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_false(nx.is_simple_path(G, [2, 1, 0]))
Пример #6
0
 def test_cycle(self):
     G = nx.cycle_graph(3)
     assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
Пример #7
0
 def test_missing_node(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 2]))
Пример #8
0
 def test_simple_path(self):
     G = nx.path_graph(2)
     assert_true(nx.is_simple_path(G, [0, 1]))
Пример #9
0
 def test_non_simple_path(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 1, 0]))
Пример #10
0
 def test_directed_cycle(self):
     G = nx.DiGraph([(0, 1), (1, 2), (2, 0)])
     assert not nx.is_simple_path(G, [0, 1, 2, 0])
Пример #11
0
 def test_multidigraph(self):
     G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 0), (1, 0)])
     assert nx.is_simple_path(G, [0, 1])
Пример #12
0
 def test_directed_non_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_false(nx.is_simple_path(G, [2, 1, 0]))
Пример #13
0
 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]))
Пример #14
0
 def test_directed_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_true(nx.is_simple_path(G, [0, 1, 2]))
Пример #15
0
 def test_missing_node(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 2]))
Пример #16
0
 def test_cycle(self):
     G = nx.cycle_graph(3)
     assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
Пример #17
0
 def test_non_simple_path(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 1, 0]))
Пример #18
0
 def test_simple_path(self):
     G = nx.path_graph(2)
     assert_true(nx.is_simple_path(G, [0, 1]))
Пример #19
0
 def test_multidigraph(self):
     G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 0), (1, 0)])
     assert_true(nx.is_simple_path(G, [0, 1]))
 def test_multigraph(self):
     G = nx.MultiGraph([(0, 1), (0, 1)])
     assert_true(nx.is_simple_path(G, [0, 1]))