Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] dijkstra_shortest_paths: weird distance to vertex (1.79769e+308)
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2013-04-15 10:42:29


On Mon, 15 Apr 2013, The Maschine wrote:

> Hi all,
> Might be something really stupid but I cant think of a problem. (maybe
> its my limited experience with BGL common pitfalls)
>
> for (boost::tie(vi, vi_end) = boost::vertices(m_ugraph); vi !=
> vi_end; ++vi) {
> depth += distances[*vi];
> .....
>
> path to:51886 distance to that node: 16.2 current total: 437998
> path to:51887 distance to that node: 16.3 current total: 438014
> path to:51888 distance to that node: 16.2 current total: 438031
> path to:51889 distance to that node: 16.2 current total: 438047
> path to:51890 distance to that node: 16.1 current total: 438063
> path to:51891 distance to that node: 16.2 current total: 438079
> path to:51892 distance to that node: 1.79769e+308 current total: 1.79769e+308
> path to:51893 distance to that node: 16.3 current total: 1.79769e+308
> path to:51894 distance to that node: 13.8 current total: 1.79769e+308
> path to:51895 distance to that node: 13.9 current total: 1.79769e+308
>
> I have checked my weights:
>
> if(edge_w<=0.0) edge_w = 0.1;
> if(edge_w >2.0) edge_w = 2.0;
> if( !(std::isnan(edge_w)) ) edge_w = 0.1;
> if( !(std::isfinite(edge_w)) ) edge_w = 0.1;
>
> boost::dijkstra_shortest_paths(m_ugraph, *vertex_iterator_begin,
> boost::distance_map(distanceMap));
>
> typedef double Weight;
> typedef boost::property<boost::edge_weight_t, double> EdgeWeightProperty;
> typedef boost::adjacency_list<boost::vecS, boost::vecS,
> boost::undirectedS, VertexProperties, EdgeWeightProperty> unGraph;

Are you sure vertex 51892 is reachable from your source vertex? If it
isn't, you would likely get that value (which is probably the maximum
finite value, so it wouldn't return true from isinf or isnan). Another
way to test this possibility is to use a predecessor map or pass in an
explicit color map and see if that is filled in for every vertex.

-- Jeremiah Willcock


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