예제 #1
0
int main()
{

  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
    boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
  typedef boost::property_map<Graph, boost::edge_weight_t>::type EdgeWeightMap;

  unsigned int numberOfVertices = 10;
  Graph g(numberOfVertices);
  for(unsigned int i = 0; i < numberOfVertices - 1; ++i)
    {
    add_edge(i, i+1, g);
    }

  std::cout << "Original graph:" << std::endl;
  boost::print_graph(g);

  vertex_id_filter<Graph> filter;
  typedef boost::filtered_graph<Graph, boost::keep_all, vertex_id_filter<Graph> > FilteredGraphType;
  FilteredGraphType filteredGraph(g, boost::keep_all(), filter); // (graph, EdgePredicate, VertexPredicate)

  std::cout << "Filtered graph:" << std::endl;
  boost::print_graph(filteredGraph);
  
  FilteredGraphType::vertex_iterator ui,ui_end; tie(ui,ui_end) = vertices(filteredGraph);

  return 0;
}
예제 #2
0
파일: mcs.cpp 프로젝트: f-alemauro/mcsGraph
    void clique(const Clique& c, const Graph& g)
    {
        vertexFilter<Clique> filterV(c);
        edgeFilter<Clique> filterE(c, g);

        typedef boost::filtered_graph<Graph, edgeFilter<Clique>, vertexFilter<Clique> > FilteredGraphType;
        FilteredGraphType filteredGraph(g, filterE, filterV); // (graph, EdgePredicate, VertexPredicate)
        Graph temp;
        boost::copy_graph(filteredGraph, temp);
        int dim = boost::num_vertices(temp);
        if(dim>maxDim) {
            maxClique = temp;
        }
        saveGraphToFile("maxClique.dot", maxClique,1);
    }