Note that there are some explanatory texts on larger screens.

plurals
  1. PONegative edge weight check in boost's dijkstra_shortest_paths
    primarykey
    data
    text
    <p>I am using the boost graph library to make a call to <code>dijkstra_shortest_paths</code>. However, I have something special setup in that the <code>weight_map</code> is actually a functor. Hence, everytime the boost library requires the weight of an edge, my functor is called, makes a complicated computation and delivers the result back to boost.</p> <p>Unfortunately, in <code>dijkstra_shortest_paths.hpp</code> the struct <code>dijkstra_bfs_visitor</code>'s method <code>examine_edge</code> has a <code>get</code> call to the weightmap, only to check if the returned value is negative. I am fully aware that I cannot use Dijkstra's algorithm with negative values and I am certain that my functor only returns positive values. However, this check causes my functor to be called twice for each edge. As it performs a complicated computation I'd like to avoid performing it twice (the results don't change between calls.. each edge gets the same wait during a <code>dijkstra_shortest_paths</code> run).</p> <p>So far, I am manually checking the edge passed to the functor and in case of the duplicate call I am returning the previous remembered result. This clearly is more of a workaround than a solution.</p> <p>I tried to pass my own visitor that overwrites <code>examine_edge</code>, however, the original method defined by boost's <code>dijkstra_bfs_visitor</code> is still applied.</p> <p>Does anyone know if there is a better way to handle this situation and somehow avoid the negate edge weight check?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload