| 1 | #include <iostream>
|
|---|
| 2 | #include <fstream>
|
|---|
| 3 | #include <string>
|
|---|
| 4 | #include <map>
|
|---|
| 5 | #include <set>
|
|---|
| 6 | #include <sstream>
|
|---|
| 7 | #include <iterator>
|
|---|
| 8 |
|
|---|
| 9 | #include <boost/graph/adjacency_list.hpp>
|
|---|
| 10 | #include <boost/graph/labeled_graph.hpp>
|
|---|
| 11 | #include <boost/graph/vf2_sub_graph_iso.hpp>
|
|---|
| 12 | #include <boost/property_map/property_map.hpp>
|
|---|
| 13 |
|
|---|
| 14 | using namespace boost;
|
|---|
| 15 |
|
|---|
| 16 | int main()
|
|---|
| 17 | {
|
|---|
| 18 | typedef property<edge_name_t, char> edge_prop;
|
|---|
| 19 | typedef property<vertex_name_t, char, property<vertex_index_t, int> > vertex_prop;
|
|---|
| 20 |
|
|---|
| 21 | //typedef adjacency_list<vecS, vecS, bidirectionalS, vertex_prop, edge_prop> Graph;
|
|---|
| 22 | typedef adjacency_list<vecS, vecS, undirectedS, vertex_prop, edge_prop> Graph;
|
|---|
| 23 | //typedef adjacency_list<setS, vecS, undirectedS, vertex_prop, edge_prop> Graph;
|
|---|
| 24 |
|
|---|
| 25 | typedef property_map<Graph, vertex_name_t>::type vertex_name_map_t;
|
|---|
| 26 | typedef property_map_equivalent<vertex_name_map_t, vertex_name_map_t> vertex_comp_t;
|
|---|
| 27 |
|
|---|
| 28 | typedef property_map<Graph, edge_name_t>::type edge_name_map_t;
|
|---|
| 29 | typedef property_map_equivalent<edge_name_map_t, edge_name_map_t> edge_comp_t;
|
|---|
| 30 |
|
|---|
| 31 | Graph graph1;
|
|---|
| 32 |
|
|---|
| 33 | add_vertex(vertex_prop('a'), graph1);
|
|---|
| 34 | add_edge(0, 0, edge_prop('a'), graph1);
|
|---|
| 35 |
|
|---|
| 36 | Graph graph2;
|
|---|
| 37 |
|
|---|
| 38 | add_vertex(vertex_prop('a'), graph2);
|
|---|
| 39 | add_edge(0, 0, edge_prop('a'), graph2);
|
|---|
| 40 |
|
|---|
| 41 | // vertex / edge predicates
|
|---|
| 42 | vertex_comp_t vertex_comp =
|
|---|
| 43 | make_property_map_equivalent(get(vertex_name, graph1), get(vertex_name, graph2));
|
|---|
| 44 | edge_comp_t edge_comp =
|
|---|
| 45 | make_property_map_equivalent(get(edge_name, graph1), get(edge_name, graph2));
|
|---|
| 46 |
|
|---|
| 47 | // compute subgraph iso
|
|---|
| 48 | std::cout << "Matched verices: " << std::endl;
|
|---|
| 49 | vf2_print_callback<Graph, Graph> callback(graph1, graph2);
|
|---|
| 50 | vf2_subgraph_iso(graph1, graph2, callback, vertex_order_by_mult(graph1),
|
|---|
| 51 | edges_equivalent(edge_comp).vertices_equivalent(vertex_comp));
|
|---|
| 52 |
|
|---|
| 53 | // out_edges
|
|---|
| 54 | std::cout << "Out edges: " << std::endl;
|
|---|
| 55 | std::set<graph_traits<Graph>::edge_descriptor> edges;
|
|---|
| 56 | graph_traits<Graph>::out_edge_iterator e, e_end;
|
|---|
| 57 | for (tie(e, e_end) = out_edges(0, graph1); e != e_end; ++e) {
|
|---|
| 58 | std::cout << "(" << source(*e, graph1)
|
|---|
| 59 | << "," << target(*e, graph1) << ")" << ", " << *e << std::endl;
|
|---|
| 60 | edges.insert(*e);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | std::cout << std::endl;
|
|---|
| 64 | std::cout << "num different edge descriptors: " << edges.size() << std::endl;
|
|---|
| 65 |
|
|---|
| 66 | return 1;
|
|---|
| 67 | }
|
|---|