I am using the boost graph library to make a call to dijkstra_shortest_paths. However, I have something special setup in that the weight_map 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.
Unfortunately, in dijkstra_shortest_paths.hpp the struct dijkstra_bfs_visitor's method examine_edge has a get 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 dijkstra_shortest_paths run).
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.
I tried to pass my own visitor that overwrites examine_edge, however, the original method defined by boost's dijkstra_bfs_visitor is still applied.
Does anyone know if there is a better way to handle this situation and somehow avoid the negate edge weight check?