[BGL] breadth_first_search with distance record and predecessors?
Hi all, Im trying to cover the dijkstra_shortest_paths call I usually do with a BFS. Id like to get back the predecessors so I can rebuild the paths and the distance to each vertex. The dijkstra_shortest_paths work for me fine! I tried a couple of BFS calls but I always get errors. What am I missing? std::vector<Vertex> predecessors(boost::num_vertices(m_ugraph)); // To store parents std::vector<Weight> distances(boost::num_vertices(m_ugraph), std::numeric_limits<double>::max() ); // To store distances IndexMap indexMap = boost::get(boost::vertex_index, m_ugraph); PredecessorMap predecessorMap(&predecessors[0], indexMap); DistanceMap distanceMap(&distances[0], indexMap); boost::dijkstra_shortest_paths(m_ugraph, s_vertex, boost::predecessor_map(predecessorMap).distance_map(distanceMap).weight_map(boost::get(&EdgeProperties::m_weight, m_ugraph)) ); //breadth_first_search(m_ugraph, s_vertex, visitor( make_bfs_visitor( record_predecessors( &predecessors, on_tree_edge() ) ) ).vertex_index_map( identity_property_map() ).record_distances(&distances.begin(),boost::on_tree_edge()) ); //boost::breadth_first_search(m_ugraph, s_vertex, boost::visitor(boost::make_bfs_visitor(std::make_pair(boost::record_distances(&distances.begin(),boost::on_tree_edge()),boost::record_predecessors(&predecessors.begin(),boost::on_tree_edge{}))))); Thanks a lot!
participants (1)
-
The Maschine