mcgregor常见的子图提升

时间:2016-09-28 15:52:57

标签: c++ boost graph subgraph

我需要使用mcgregor_common_subgraphs,但在这个具体的例子中并不真正理解如何使用它,它不是孔src代码,如果有人有 任何想法,我会编辑其余的,只是让我知道!

#include <fstream>
#include <iostream>
#include <string>

#include <boost/lexical_cast.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/property_map/shared_array_property_map.hpp>

#include <boost/config.hpp>
#include <boost/graph/mcgregor_common_subgraphs.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/lookup_edge.hpp>
#include <boost/graph/subgraph.hpp>
#include <vector>

using namespace boost;

typedef subgraph<adjacency_list<vecS, vecS, undirectedS,  
property<vertex_color_t, int>,    property<edge_name_t, int,
property<edge_index_t, int>>, property<vertex_name_t, int,  
property<vertex_index_t,  int>>  >> Graph;

int main(int argc, char *argv[]) {

const int N = 6;
enum { A, B, C, D, E, F }; // for conveniently refering to vertices in G0

Graph G0(N);
Graph& G1 = G0.create_subgraph();
Graph& G2 = G0.create_subgraph();
Graph& G3 = G0.create_subgraph();
Graph& G4 = G0.create_subgraph();
Graph& G5 = G0.create_subgraph();
Graph& G6 = G0.create_subgraph();
Graph& G7 = G0.create_subgraph();

enum { A1, B1, C1 }; // for conveniently refering to vertices in G1
enum { A2, B2 };     // for conveniently refering to vertices in G2
enum { A3, B3 };
enum { A4, B4, C4 };
enum { A5, B5 };
enum { A6, B6, C6 };
enum { A7, B7 };

add_vertex(C, G1); // global vertex C becomes local A1 for G1
add_vertex(E, G1); // global vertex E becomes local B1 for G1
add_vertex(F, G1); // global vertex F becomes local C1 for G1

add_vertex(A, G2); // global vertex A becomes local A1 for G2
add_vertex(B, G2); // global vertex B becomes local B1 for G2

add_vertex(B, G3); // ...-||-...
add_vertex(C, G3);

add_vertex(A, G4);
add_vertex(B, G4);
add_vertex(E, G4);

add_vertex(F, G5);
add_vertex(D, G5);

add_vertex(B, G6);
add_vertex(D, G6);
add_vertex(E, G6);

add_vertex(F, G7);
add_vertex(B, G7);
add_vertex(D, G7);

add_edge(A, B, G0);
add_edge(B, C, G0);
add_edge(B, D, G0);
add_edge(E, B, G0);
add_edge(E, F, G0);
add_edge(F, D, G0);

0 个答案:

没有答案