Esempio n. 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']))
Esempio n. 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]))
Esempio n. 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, []))
Esempio n. 4
0
 def test_directed_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_true(nx.is_simple_path(G, [0, 1, 2]))
Esempio n. 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]))
Esempio n. 6
0
 def test_cycle(self):
     G = nx.cycle_graph(3)
     assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
Esempio n. 7
0
 def test_missing_node(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 2]))
Esempio n. 8
0
 def test_simple_path(self):
     G = nx.path_graph(2)
     assert_true(nx.is_simple_path(G, [0, 1]))
Esempio n. 9
0
 def test_non_simple_path(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 1, 0]))
Esempio n. 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])
Esempio n. 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])
Esempio n. 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]))
Esempio n. 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]))
Esempio n. 14
0
 def test_directed_path(self):
     G = nx.DiGraph([(0, 1), (1, 2)])
     assert_true(nx.is_simple_path(G, [0, 1, 2]))
Esempio n. 15
0
 def test_missing_node(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 2]))
Esempio n. 16
0
 def test_cycle(self):
     G = nx.cycle_graph(3)
     assert_false(nx.is_simple_path(G, [0, 1, 2, 0]))
Esempio n. 17
0
 def test_non_simple_path(self):
     G = nx.path_graph(2)
     assert_false(nx.is_simple_path(G, [0, 1, 0]))
Esempio n. 18
0
 def test_simple_path(self):
     G = nx.path_graph(2)
     assert_true(nx.is_simple_path(G, [0, 1]))
Esempio n. 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]))