Esempio n. 1
0
 def test_example(self):
     G = nx.Graph()
     G_edges = [
         [1, 2],
         [1, 3],
         [1, 4],
         [1, 5],
         [2, 3],
         [2, 5],
         [2, 6],
         [2, 7],
         [3, 4],
         [3, 5],
         [6, 7],
         [6, 8],
         [7, 8],
     ]
     G.add_edges_from(G_edges)
     H = nx.inverse_line_graph(G)
     solution = nx.Graph()
     solution_edges = [
         ("a", "b"),
         ("a", "c"),
         ("a", "d"),
         ("a", "e"),
         ("c", "d"),
         ("e", "f"),
         ("e", "g"),
         ("f", "g"),
     ]
     solution.add_edges_from(solution_edges)
     assert nx.is_isomorphic(H, solution)
Esempio n. 2
0
 def test_triangle_graph(self):
     G = nx.complete_graph(3)
     H = nx.inverse_line_graph(G)
     alternative_solution = nx.Graph()
     alternative_solution.add_edges_from([[0, 1], [0, 2], [0, 3]])
     # there are two alternative inverse line graphs for this case
     # so long as we get one of them the test should pass
     assert_true(nx.is_isomorphic(H, G) or
                 nx.is_isomorphic(H, alternative_solution))
 def test_triangle_graph(self):
     G = nx.complete_graph(3)
     H = nx.inverse_line_graph(G)
     alternative_solution = nx.Graph()
     alternative_solution.add_edges_from([[0, 1], [0, 2], [0, 3]])
     # there are two alternative inverse line graphs for this case
     # so long as we get one of them the test should pass
     assert (nx.is_isomorphic(H, G)
             or nx.is_isomorphic(H, alternative_solution))
 def test_example_2(self):
     G = nx.Graph()
     G_edges = [[1, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 5]]
     G.add_edges_from(G_edges)
     H = nx.inverse_line_graph(G)
     solution = nx.Graph()
     solution_edges = [('a', 'c'), ('b', 'c'), ('c', 'd'), ('d', 'e'),
                       ('d', 'f')]
     solution.add_edges_from(solution_edges)
     assert nx.is_isomorphic(H, solution)
Esempio n. 5
0
 def test_example_2(self):
     G = nx.Graph()
     G_edges = [[1, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 5]]
     G.add_edges_from(G_edges)
     H = nx.inverse_line_graph(G)
     solution = nx.Graph()
     solution_edges = [("a", "c"), ("b", "c"), ("c", "d"), ("d", "e"),
                       ("d", "f")]
     solution.add_edges_from(solution_edges)
     assert nx.is_isomorphic(H, solution)
Esempio n. 6
0
 def test_example(self):
     G = nx.Graph()
     G_edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 5], [2, 6],
                [2, 7], [3, 4], [3, 5], [6, 7], [6, 8], [7, 8]]
     G.add_edges_from(G_edges)
     H = nx.inverse_line_graph(G)
     solution = nx.Graph()
     solution_edges = [('a', 'b'), ('a', 'c'), ('a', 'd'), ('a', 'e'),
                       ('c', 'd'), ('e', 'f'), ('e', 'g'), ('f', 'g')]
     solution.add_edges_from(solution_edges)
     assert_true(nx.is_isomorphic(H, solution))
Esempio n. 7
0
 def test_example(self):
     G = nx.Graph()
     G_edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 5], [2, 6],
                [2, 7], [3, 4], [3, 5], [6, 7], [6, 8], [7, 8]]
     G.add_edges_from(G_edges)
     H = nx.inverse_line_graph(G)
     solution = nx.Graph()
     solution_edges = [('a', 'b'), ('a', 'c'), ('a', 'd'), ('a', 'e'),
                       ('c', 'd'), ('e', 'f'), ('e', 'g'), ('f', 'g')]
     solution.add_edges_from(solution_edges)
     assert_true(nx.is_isomorphic(H, solution))
 def test_K1(self):
     G = nx.complete_graph(1)
     H = nx.inverse_line_graph(G)
     solution = nx.path_graph(2)
     assert nx.is_isomorphic(H, solution)
 def test_empty(self):
     G = nx.Graph()
     H = nx.inverse_line_graph(G)
     assert nx.is_isomorphic(H, nx.complete_graph(1))
 def test_cycle(self):
     G = nx.cycle_graph(5)
     H = nx.inverse_line_graph(G)
     assert nx.is_isomorphic(H, G)
Esempio n. 11
0
 def test_line_inverse_line_path(self):
     G = nx.path_graph(10)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
 def test_line(self):
     G = nx.path_graph(5)
     solution = nx.path_graph(6)
     H = nx.inverse_line_graph(G)
     assert nx.is_isomorphic(H, solution)
Esempio n. 13
0
 def test_pair(self):
     G = nx.path_graph(2)
     H = nx.inverse_line_graph(G)
     solution = nx.path_graph(3)
     assert_true(nx.is_isomorphic(H, solution))
 def test_line_inverse_line_cycle(self):
     G = nx.cycle_graph(10)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
Esempio n. 15
0
 def test_line_inverse_line_star(self):
     G = nx.star_graph(20)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
 def test_line_inverse_line_multipartite(self):
     G = nx.complete_multipartite_graph(3, 4, 5)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
Esempio n. 17
0
 def test_line_inverse_line_complete(self):
     G = nx.complete_graph(10)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
Esempio n. 18
0
 def test_cycle(self):
     G = nx.cycle_graph(5)
     H = nx.inverse_line_graph(G)
     assert_true(nx.is_isomorphic(H, G))
Esempio n. 19
0
 def test_line_inverse_line_multipartite(self):
     G = nx.complete_multipartite_graph(3, 4, 5)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
Esempio n. 20
0
 def test_line(self):
     G = nx.path_graph(5)
     solution = nx.path_graph(6)
     H = nx.inverse_line_graph(G)
     assert_true(nx.is_isomorphic(H, solution))
 def test_line_inverse_line_path(self):
     G = nx.path_graph(10)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
Esempio n. 22
0
 def test_line_inverse_line_hypercube(self):
     G = nx.hypercube_graph(5)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
 def test_line_inverse_line_hypercube(self):
     G = nx.hypercube_graph(5)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
 def test_pair(self):
     G = nx.path_graph(2)
     H = nx.inverse_line_graph(G)
     solution = nx.path_graph(3)
     assert nx.is_isomorphic(H, solution)
 def test_line_inverse_line_star(self):
     G = nx.star_graph(20)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
Esempio n. 26
0
 def test_line_inverse_line_dgm(self):
     G = nx.dorogovtsev_goltsev_mendes_graph(4)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))
 def test_line_inverse_line_dgm(self):
     G = nx.dorogovtsev_goltsev_mendes_graph(4)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert nx.is_isomorphic(G, J)
Esempio n. 28
0
 def test_line_inverse_line_complete(self):
     G = nx.complete_graph(10)
     H = nx.line_graph(G)
     J = nx.inverse_line_graph(H)
     assert_true(nx.is_isomorphic(G, J))