[Lemon-user] Dijkstra Problem

Alpar Juttner alpar at cs.elte.hu
Sat Mar 9 09:00:37 CET 2013


Hi,

> I found my mistake. It appears that even though the path costs
> infinity Dijkstra says that it found one and then “inf – inf = NaN” .
> It would be nice if bool run(source,target) returns false when the
> cost of the path is infinite.

It is not possible, because not all numerical type (e.g integer) can
represent "infinite". In addition, others may also want to consider
paths with infinite cost.

Instead, you should
      * either check length of the path with dist(t) after run(s,t) or
      * (may even be better) remove the edges with infinite cost. I
        guess you use infinite cost for temporarily disabling edges. For
        this purpose you may also want to consider uses the
        FilterArcs/FilterEdges graph adaptor class.

Alpar





More information about the Lemon-user mailing list