Opened 11 years ago
Closed 11 years ago
#5659 closed Bugs (fixed)
The closed_plus structure should accept a custom infinity value.
Reported by: | Owned by: | Jeremiah Willcock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | graph |
Version: | Boost 1.46.1 | Severity: | Problem |
Keywords: | Cc: |
Description
I'm trying to run dijkstra_shortest_paths with a custom distance type (my graph supports two metrics, I want to find the length in metric A of the shortest paths according to metric B).
I've been struggling to understand why I was getting dependencies on MyDistType(int). It turns out that overloading + on MyDistType is only half the story. The default combine operator for distances comes from closed_plus, which assumes an infinity value can be constructed by std::numeric_limits<D>::max(). This function seems to degrade to trying the constructor T(n) for some int n (probably INT_MAX) if it isn't a known numeric type, leading to bizarre errors (buried under piles of template goop).
This patch gives instances of closed_plus a parameter to store the custom infinity value, defaulting to the one from std::numeric_limits. It also passes the correct default value in dijkstra_shortest_paths. I haven't checked whether any of the other algorithms that use closed_plus can potentially have non-standard infinity values.
Hope you agree this is an improvement.
Yours,
Thomas.
Attachments (1)
Change History (4)
by , 11 years ago
comment:1 by , 11 years ago
An alternative fix, of course, would be to make it clear in the documentation of dijkstra_shortest_paths and similar that if you supply your own distance_inf then you *must* supply your own distance_combine, and/or to mandate that with a compile-time assertion in the named parameters interpreter.
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
diff