Boost logo

Boost Users :

From: Peter Gerell (boost_at_[hidden])
Date: 2006-02-16 09:03:43


Hi,
I am had sime difficulties using the johnson_all_pairs_shortest_path
algorithm.
I have a custom weight type called CostType.
I tried calling the algorithm as follows.

  johnson_all_pairs_shortest_paths(g, D,
distance_inf(CostType::infinity()));

The result was a distance matrix with all zeros.
The problem is the following lines from johnson_all_pairs_shortest_path.hpp

  DT inf = (std::numeric_limits<DT>::max)();
  for (tie(v, v_end) = vertices(g2); v != v_end; ++v)
    d[*v] = inf;

If I specialized the numerical-limits class for CostType everything started
to work as expected.

namespace std {
  template<>
  class numeric_limits<CostType> {
  public:
    inline static CostType min() throw() { return -CostType::infinity();}
    inline static CostType max() throw() { return CostType::infinity(); }
  };
}

Even if this is the good way to solve the problem, it doesn't work for what
I want to do.
I'm trying to calculate the longest paths by redefining distance_inf and
distance_compare.

Is this a bug or is it something I don't understand?
I am using boost 1.33.1
/Peter


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