Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-09-03 10:57:37


Hi Joel,

Edge weights do not have to be signed types, however, the type you use
must have a version of std::abs() defined for it.

Urgh, the "std::swap() issue" rears its ugly head again!

Here's a couple of possible workarounds:

1. define a std::abs for unsigned int. This is illegal according
to the C++ standard, but will work.

2. I change the std::abs() call in relax to just plain abs() and put a
using std::abs in front. Then you define an abs() for unsigned
int in the global namespace.

I think the better option is 2), so I'll go ahead and make that change.

On Mon, 3 Sep 2001, Joel Young wrote:
jdy>
jdy> Hi,
jdy>
jdy> With gcc-2.95.3, if the "edge_weight_t" is "unsigned int" in the
jdy> edge properties, than with dijkstra_shortest_path I get the following
jdy> error:
jdy>
jdy> .../boost_1_24_0/boost/graph/dijkstra_shortest_paths.hpp:189: instantiated from here
jdy> .../boost_1_24_0/boost/graph/relax.hpp:65: call of overloaded `abs (unsigned int)' is ambiguous
jdy> /usr/include/stdlib.h:699: candidates are: int abs(int)
jdy> .../include/g++-3/cstdlib:17: long int abs(long int)
jdy> .../include/g++-3/cmath:40: float abs(float)
jdy> .../include/g++-3/cmath:42: double abs(double)
jdy> .../include/g++-3/cmath:72: long double abs(long double)
jdy>
jdy> If I change the edge_weight_t to "long int" for example it build fine.
jdy> Must edge weights be signed types?
jdy>
jdy>
jdy> Also, it would be nice if there was an example on using the
jdy> dijkstra_shortest_paths with no external maps.

Okidoke.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-9761
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk