Boost logo

Boost Users :

Subject: [Boost-users] [BGL] breadth_first_search with distance record and predecessors?
From: The Maschine (justthemaschine_at_[hidden])
Date: 2016-06-06 06:38:32


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!



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net