inline void dijkstra_shortest_paths_no_init (const Graph& g, SourceInputIter s_begin, SourceInputIter s_end, PredecessorMap predecessor, DistanceMap distance, WeightMap weight, IndexMap index_map, Compare compare, Combine combine, DistZero zero, DijkstraVisitor vis, ColorMap color) { typedef indirect_cmp<DistanceMap, Compare> IndirectCmp; IndirectCmp icmp(distance, compare); typedef typename graph_traits<Graph>::vertex_descriptor Vertex; #ifdef BOOST_GRAPH_DIJKSTRA_TESTING if (!dijkstra_relaxed_heap) { typedef mutable_queue<Vertex, std::vector<Vertex>, IndirectCmp, IndexMap> MutableQueue; MutableQueue Q(num_vertices(g), icmp, index_map); detail::dijkstra_bfs_visitor<DijkstraVisitor, MutableQueue, WeightMap, PredecessorMap, DistanceMap, Combine, Compare> bfs_vis(vis, Q, weight, predecessor, distance, combine, compare, zero); breadth_first_visit(g, s_begin, s_end, Q, bfs_vis, color); return; } #endif // BOOST_GRAPH_DIJKSTRA_TESTING #ifdef BOOST_GRAPH_DIJKSTRA_USE_RELAXED_HEAP typedef relaxed_heap<Vertex, IndirectCmp, IndexMap> MutableQueue; MutableQueue Q(num_vertices(g), icmp, index_map); #else // Now the default: use a d-ary heap boost::scoped_array<std::size_t> index_in_heap_map_holder; typedef detail::vertex_property_map_generator<Graph, IndexMap, std::size_t> IndexInHeapMapHelper; typedef typename IndexInHeapMapHelper::type IndexInHeapMap; IndexInHeapMap index_in_heap = IndexInHeapMapHelper::build(g, index_map, index_in_heap_map_holder); typedef d_ary_heap_indirect<Vertex, 4, IndexInHeapMap, DistanceMap, Compare> MutableQueue; MutableQueue Q(distance, index_in_heap, compare); #endif // Relaxed heap detail::dijkstra_bfs_visitor<DijkstraVisitor, MutableQueue, WeightMap, PredecessorMap, DistanceMap, Combine, Compare> bfs_vis(vis, Q, weight, predecessor, distance, combine, compare, zero); breadth_first_visit(g, s_begin, s_end, Q, bfs_vis, color); }
inline void dijkstra_shortest_paths_no_init (const VertexListGraph& g, typename graph_traits<VertexListGraph>::vertex_descriptor s, PredecessorMap predecessor, DistanceMap distance, WeightMap weight, IndexMap index_map, Compare compare, Combine combine, DistInf inf, DistZero zero, DijkstraVisitor vis) { typedef indirect_cmp<DistanceMap, Compare> IndirectCmp; IndirectCmp icmp(distance, compare); typedef typename graph_traits<VertexListGraph>::vertex_descriptor Vertex; typedef mutable_queue<Vertex, std::vector<Vertex>, IndirectCmp, IndexMap> MutableQueue; MutableQueue Q(num_vertices(g), icmp, index_map); detail::dijkstra_bfs_visitor<DijkstraVisitor, MutableQueue, WeightMap, PredecessorMap, DistanceMap, Combine, Compare> bfs_vis(vis, Q, weight, predecessor, distance, combine, compare, zero); std::vector<default_color_type> color(num_vertices(g)); default_color_type c = white_color; breadth_first_visit(g, s, Q, bfs_vis, make_iterator_property_map(&color[0], index_map, c)); }
void breadth_first_visit (const IncidenceGraph& g, typename graph_traits<IncidenceGraph>::vertex_descriptor s, const bgl_named_params<P, T, R>& params) { // The graph is passed by *const* reference so that graph adaptors // (temporaries) can be passed into this function. However, the // graph is not really const since we may write to property maps // of the graph. IncidenceGraph& ng = const_cast<IncidenceGraph&>(g); typedef graph_traits<IncidenceGraph> Traits; // Buffer default typedef typename Traits::vertex_descriptor vertex_descriptor; typedef boost::queue<vertex_descriptor> queue_t; queue_t Q; detail::wrap_ref<queue_t> Qref(Q); breadth_first_visit (ng, s, choose_param(get_param(params, buffer_param_t()), Qref).ref, choose_param(get_param(params, graph_visitor), make_bfs_visitor(null_visitor())), choose_pmap(get_param(params, vertex_color), ng, vertex_color) ); }
inline void astar_search_no_init (const VertexListGraph &g, typename graph_traits<VertexListGraph>::vertex_descriptor s, AStarHeuristic h, AStarVisitor vis, PredecessorMap predecessor, CostMap cost, DistanceMap distance, WeightMap weight, ColorMap color, VertexIndexMap index_map, CompareFunction compare, CombineFunction combine, CostInf /*inf*/, CostZero zero) { typedef typename graph_traits<VertexListGraph>::vertex_descriptor Vertex; typedef boost::vector_property_map<std::size_t, VertexIndexMap> IndexInHeapMap; IndexInHeapMap index_in_heap(index_map); typedef d_ary_heap_indirect<Vertex, 4, IndexInHeapMap, CostMap, CompareFunction> MutableQueue; MutableQueue Q(cost, index_in_heap, compare); detail::astar_bfs_visitor<AStarHeuristic, AStarVisitor, MutableQueue, PredecessorMap, CostMap, DistanceMap, WeightMap, ColorMap, CombineFunction, CompareFunction> bfs_vis(h, vis, Q, predecessor, cost, distance, weight, color, combine, compare, zero); breadth_first_visit(g, s, Q, bfs_vis, color); }
void breadth_first_visit (const IncidenceGraph& g, typename graph_traits<IncidenceGraph>::vertex_descriptor s, Buffer& Q, BFSVisitor vis, ColorMap color) { typename graph_traits<IncidenceGraph>::vertex_descriptor sources[1] = {s}; breadth_first_visit(g, sources, sources + 1, Q, vis, color); }
void breadth_first_search (const VertexListGraph& g, SourceIterator sources_begin, SourceIterator sources_end, Buffer& Q, BFSVisitor vis, ColorMap color) { // Initialization typedef typename property_traits<ColorMap>::value_type ColorValue; typedef color_traits<ColorValue> Color; typename boost::graph_traits<VertexListGraph>::vertex_iterator i, i_end; for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) { vis.initialize_vertex(*i, g); put(color, *i, Color::white()); } breadth_first_visit(g, sources_begin, sources_end, Q, vis, color); }
Vertex pseudo_peripheral_pair(Graph const& G, const Vertex& u, int& ecc, ColorMap color, DegreeMap degree) { typedef typename property_traits<ColorMap>::value_type ColorValue; typedef color_traits<ColorValue> Color; sparse::rcm_queue<Vertex, DegreeMap> Q(degree); typename boost::graph_traits<Graph>::vertex_iterator ui, ui_end; for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) if (get(color, *ui) != Color::red()) put(color, *ui, Color::white()); breadth_first_visit(G, u, buffer(Q).color_map(color)); ecc = Q.eccentricity(); return Q.spouse(); }