예제 #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]))