void set_all_afparams(const std::vector<typename af_t::params_t>& afs) { assert(num_vertices(_g) == afs.size()); size_t k = 0; BGL_FORALL_VERTICES_T(v, _g, graph_t) _g[v].set_afparamst(afs[k++]); }
void random_spanning_tree_internal(const Graph& g, typename graph_traits<Graph>::vertex_descriptor s, PredMap pred, ColorMap color, NextEdge next_edge) { typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor; typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor; assert (num_vertices(g) >= 1); // g must also be undirected (or symmetric) and connected typedef color_traits<typename property_traits<ColorMap>::value_type> color_gen; BGL_FORALL_VERTICES_T(v, g, Graph) put(color, v, color_gen::white()); std::vector<vertex_descriptor> path; put(color, s, color_gen::black()); put(pred, s, graph_traits<Graph>::null_vertex()); BGL_FORALL_VERTICES_T(v, g, Graph) { if (get(color, v) != color_gen::white()) continue; loop_erased_random_walk(g, v, next_edge, color, path); for (typename std::vector<vertex_descriptor>::const_reverse_iterator i = path.rbegin(); boost::next(i) != (typename std::vector<vertex_descriptor>::const_reverse_iterator)path.rend(); ++i) { typename std::vector<vertex_descriptor>::const_reverse_iterator j = i; ++j; assert (get(color, *j) == color_gen::gray()); put(color, *j, color_gen::black()); put(pred, *j, *i); } } }
bool operator()(CorrespondenceMap1To2 f, CorrespondenceMap2To1) const { // Print (sub)graph isomorphism map BGL_FORALL_VERTICES_T(v, graph1_, Graph1) std::cout << '(' << get(vertex_index_t(), graph1_, v) << ", " << get(vertex_index_t(), graph1_, get(f, v)) << ") "; std::cout << std::endl; return true; }
void page_rank_step(const Graph& g, RankMap from_rank, RankMap2 to_rank, typename property_traits<RankMap>::value_type damping, incidence_graph_tag) { typedef typename property_traits<RankMap>::value_type rank_type; // Set new rank maps BGL_FORALL_VERTICES_T(v, g, Graph) put(to_rank, v, rank_type(1 - damping)); BGL_FORALL_VERTICES_T(u, g, Graph) { rank_type u_rank_out = damping * get(from_rank, u) / out_degree(u, g); BGL_FORALL_ADJ_T(u, v, g, Graph) put(to_rank, v, get(to_rank, v) + u_rank_out); }
static void run_impl(const DistributedGraph& g, typename graph_traits<DistributedGraph>::vertex_descriptor s, PredecessorMap predecessor, DistanceMap distance, Lookahead lookahead, WeightMap weight, IndexMap index_map, ColorMap color_map, Compare compare, Combine combine, DistInf inf, DistZero zero, DijkstraVisitor vis) { BGL_FORALL_VERTICES_T(u, g, DistributedGraph) BGL_FORALL_OUTEDGES_T(u, e, g, DistributedGraph) local_put(color_map, target(e, g), white_color); graph::detail::parallel_dijkstra_impl2<Lookahead> ::run(g, s, predecessor, distance, lookahead, weight, index_map, color_map, compare, combine, inf, zero, vis); }
bool st_connected(const Graph& g, typename graph_traits<Graph>::vertex_descriptor s, typename graph_traits<Graph>::vertex_descriptor t, ColorMap color) { typedef typename property_traits<ColorMap>::value_type Color; typedef color_traits<Color> ColorTraits; typedef typename graph_traits<Graph>::vertex_descriptor Vertex; // Set all vertices to white (unvisited) BGL_FORALL_VERTICES_T(v, g, Graph) put(color, v, ColorTraits::white()); // Vertices found from the source are grey put(color, s, ColorTraits::gray()); // Vertices found from the target are greeen put(color, t, ColorTraits::green()); queue<Vertex> Q; Q.push(s); Q.push(t); while (!Q.empty()) { Vertex u = Q.top(); Q.pop(); Color u_color = get(color, u); BGL_FORALL_OUTEDGES_T(u, e, g, Graph) { Vertex v = target(e, g); Color v_color = get(color, v); if (v_color == ColorTraits::white()) { // We have not seen "v" before; mark it with the same color as u Color u_color = get(color, u); put(color, v, u_color); // Push it on the queue Q.push(v); } else if (v_color != ColorTraits::black() && u_color != v_color) { // Colors have collided. We're done! return true; } } // u is done, so mark it black put(color, u, ColorTraits::black()); }
void copy_vertex_property(PropertyIn p_in, PropertyOut p_out, Graph& g) { BGL_FORALL_VERTICES_T(u, g, Graph) put(p_out, u, get(p_in, g)); }
bool test_isomorphism() { { std::vector<invar1_value> invar1_array; BGL_FORALL_VERTICES_T(v, G1, Graph1) invar1_array.push_back(invariant1(v)); sort(invar1_array); std::vector<invar2_value> invar2_array; BGL_FORALL_VERTICES_T(v, G2, Graph2) invar2_array.push_back(invariant2(v)); sort(invar2_array); if (! equal(invar1_array, invar2_array)) return false; } std::vector<vertex1_t> V_mult; BGL_FORALL_VERTICES_T(v, G1, Graph1) V_mult.push_back(v); { std::vector<size_type> multiplicity(max_invariant, 0); BGL_FORALL_VERTICES_T(v, G1, Graph1) ++multiplicity[invariant1(v)]; sort(V_mult, compare_multiplicity(invariant1, &multiplicity[0])); } std::vector<default_color_type> color_vec(num_vertices(G1)); safe_iterator_property_map<std::vector<default_color_type>::iterator, IndexMap1 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , default_color_type, default_color_type& #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ > color_map(color_vec.begin(), color_vec.size(), index_map1); record_dfs_order dfs_visitor(dfs_vertices, ordered_edges); typedef color_traits<default_color_type> Color; for (vertex_iter u = V_mult.begin(); u != V_mult.end(); ++u) { if (color_map[*u] == Color::white()) { dfs_visitor.start_vertex(*u, G1); depth_first_visit(G1, *u, dfs_visitor, color_map); } } // Create the dfs_num array and dfs_num_map dfs_num_vec.resize(num_vertices(G1)); dfs_num = make_safe_iterator_property_map(dfs_num_vec.begin(), dfs_num_vec.size(), index_map1 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , dfs_num_vec.front() #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ ); size_type n = 0; for (vertex_iter v = dfs_vertices.begin(); v != dfs_vertices.end(); ++v) dfs_num[*v] = n++; sort(ordered_edges, edge_cmp(G1, dfs_num)); int dfs_num_k = -1; return this->match(ordered_edges.begin(), dfs_num_k); }