Exemplo n.º 1
0
 def test_digraph_vf2_number_of_valid_mappings(self):
     graph = retworkx.generators.directed_mesh_graph(3)
     mapping = retworkx.digraph_vf2_mapping(graph, graph, id_order=True)
     total = 0
     for _ in mapping:
         total += 1
     self.assertEqual(total, 6)
Exemplo n.º 2
0
 def test_digraph_vf2_mapping_identical_vf2pp(self):
     graph = retworkx.generators.directed_grid_graph(2, 2)
     second_graph = retworkx.generators.directed_grid_graph(2, 2)
     mapping = retworkx.digraph_vf2_mapping(graph,
                                            second_graph,
                                            id_order=False)
     self.assertEqual(next(mapping), {0: 0, 1: 1, 2: 2, 3: 3})
Exemplo n.º 3
0
 def test_digraph_vf2_mapping_identical_removals_first(self):
     second_graph = retworkx.generators.directed_path_graph(2)
     graph = retworkx.generators.directed_path_graph(4)
     graph.remove_nodes_from([1, 2])
     graph.add_edge(0, 3, None)
     mapping = retworkx.digraph_vf2_mapping(graph, second_graph)
     self.assertEqual({0: 0, 3: 1}, next(mapping))
Exemplo n.º 4
0
 def test_subgraph_vf2_mapping(self):
     graph = retworkx.generators.directed_grid_graph(10, 10)
     second_graph = retworkx.generators.directed_grid_graph(2, 2)
     mapping = retworkx.digraph_vf2_mapping(graph,
                                            second_graph,
                                            subgraph=True)
     self.assertEqual(next(mapping), {0: 0, 1: 1, 10: 2, 11: 3})
Exemplo n.º 5
0
 def test_subgraph_vf2_mapping_vf2pp(self):
     graph = retworkx.generators.directed_grid_graph(3, 3)
     second_graph = retworkx.generators.directed_grid_graph(2, 2)
     mapping = retworkx.digraph_vf2_mapping(graph,
                                            second_graph,
                                            subgraph=True,
                                            id_order=False)
     self.assertEqual(next(mapping), {4: 0, 5: 1, 7: 2, 8: 3})
Exemplo n.º 6
0
 def test_digraph_vf2_mapping_identical_removals_vf2pp(self):
     graph = retworkx.generators.directed_path_graph(2)
     second_graph = retworkx.generators.directed_path_graph(4)
     second_graph.remove_nodes_from([1, 2])
     second_graph.add_edge(0, 3, None)
     mapping = retworkx.digraph_vf2_mapping(graph,
                                            second_graph,
                                            id_order=False)
     self.assertEqual({0: 0, 1: 3}, next(mapping))
Exemplo n.º 7
0
 def test_subgraph_vf2_all_mappings(self):
     graph = retworkx.generators.directed_path_graph(3)
     second_graph = retworkx.generators.directed_path_graph(2)
     mapping = retworkx.digraph_vf2_mapping(graph,
                                            second_graph,
                                            subgraph=True,
                                            id_order=True)
     self.assertEqual(next(mapping), {0: 0, 1: 1})
     self.assertEqual(next(mapping), {2: 1, 1: 0})
Exemplo n.º 8
0
 def test_empty_digraph_vf2_mapping(self):
     g_a = retworkx.PyDiGraph()
     g_b = retworkx.PyDiGraph()
     for id_order in [False, True]:
         with self.subTest(id_order=id_order):
             mapping = retworkx.digraph_vf2_mapping(g_a,
                                                    g_b,
                                                    id_order=id_order,
                                                    subgraph=False)
             self.assertEqual({}, next(mapping))
Exemplo n.º 9
0
    def test_vf2pp_remapping(self):
        temp = retworkx.generators.directed_grid_graph(3, 3)

        graph = retworkx.PyDiGraph()
        dummy = graph.add_node(0)

        graph.compose(temp, dict())
        graph.remove_node(dummy)

        second_graph = retworkx.generators.directed_grid_graph(2, 2)
        mapping = retworkx.digraph_vf2_mapping(graph,
                                               second_graph,
                                               subgraph=True,
                                               id_order=False)
        self.assertEqual(next(mapping), {5: 0, 6: 1, 8: 2, 9: 3})