[graph] BFS and dedicated color map

The BGL implementation of breadth-first search uses a dedicated color map.
I had the following idea: Some algorithms don't need to distinguish
black/gray, but have an unused value in e.g. a distance map, e.g. -1, to
which the map can be initialised.
So I tried to write a map adapter which can be passed such a map
together with the value indicating "white". This adapter will return
white whenever the value in the underlying map equals this value, black
otherwise.
Unfortunately, my C++ seems to be too bad to implement this ...
Please see the attached source files ...
The errors I'm currently getting:
In file included from bfs_map_test.cpp:14:
bfs_distmap_as_color_map.hpp:42: error: ISO C++ forbids declaration of
`graph_traits' with no type
bfs_distmap_as_color_map.hpp:42: error: expected `;' before '<' token
bfs_distmap_as_color_map.hpp:47: error: `key_type' has not been declared
bfs_distmap_as_color_map.hpp:47: error: ISO C++ forbids declaration of
`key' with no type
bfs_distmap_as_color_map.hpp:62: error: `ColorValue MapAsColorMap

Jens Müller schrieb:
Unfortunately, my C++ seems to be too bad to implement this ...
Please see the attached source files ...
The errors I'm currently getting:
OK, fixed some missing boost::, and used size_t* instead of size_t[] as
the template parameter for the pmap type.
Still get errors:
bfs_map_test.cpp: In function `int main(int, char**)':
bfs_map_test.cpp:69: error: no matching function for call to
`MapAsColorMap

Jens Müller schrieb:
Jens Müller schrieb:
Unfortunately, my C++ seems to be too bad to implement this ...
Please see the attached source files ...
The errors I'm currently getting:
OK, fixed some missing boost::, and used size_t* instead of size_t[] as the template parameter for the pmap type.
Still get errors:
bfs_map_test.cpp: In function `int main(int, char**)': bfs_map_test.cpp:69: error: no matching function for call to `MapAsColorMap
::MapAsColorMap(size_t[5], int)' bfs_distmap_as_color_map.hpp:40: note: candidates are: MapAsColorMap ::MapAsColorMap(const MapAsColorMap &) bfs_distmap_as_color_map.hpp:48: note: MapAsColorMap ::MapAsColorMap(ReadablePropertyMap&, typename boost::property_traits<IndexMap>::value_type) [with Graph = main(int, char**)::Graph, ReadablePropertyMap = size_t*, ColorValue = int] Can someone please help me?
This works:
template

Jens, the ReadablePropertyMap parameter has to be a class with the following typedef at least: typedef value_type some_type; -----Original Message----- Can someone please help me?

Dmitry schrieb:
Jens, the ReadablePropertyMap parameter has to be a class with the following typedef at least:
typedef value_type some_type;
Why? http://www.boost.org/libs/property_map/ReadablePropertyMap.html says: Associated Types Value Type boost::property_traits<PMap>::value_type The type of the property. That's what these traits classes are for: external adaption. You replied to the fixed version where I use property_traits.

Hi, Jens,
I was able to reduce the number of compilation errors from 32 to 27 by
adding namespace boost everywhere (BGL is described in the namespace boost)
and some other minor changes.
Now the compilation error is in the test file due to incorrect ussage of
your adaptor (I guess):
1>d:\documents and settings\dmitry\my documents\visual studio
2005\projects\bgl_users_help\bgl_users_help\bfs_distmap_as_color_map.hpp(50)
: error C2825: 'ReadablePropertyMap': must be a class or namespace when
followed by '::'
1> d:\documents and settings\dmitry\my documents\visual studio
2005\projects\bgl_users_help\bgl_users_help\bfs_map_test.cpp(68) : see
reference to class template instantiation
'boost::MapAsColorMap

Dmitry schrieb:
Hi, Jens, I was able to reduce the number of compilation errors from 32 to 27 by adding namespace boost everywhere (BGL is described in the namespace boost) and some other minor changes. Now the compilation error is in the test file due to incorrect ussage of your adaptor (I guess): 1>d:\documents and settings\dmitry\my documents\visual studio 2005\projects\bgl_users_help\bgl_users_help\bfs_distmap_as_color_map.hpp(50) : error C2825: 'ReadablePropertyMap': must be a class or namespace when followed by '::'
Well, I forgot to use property_traits there - but I still have problems, see the other posts ...
participants (2)
-
Dmitry
-
Jens Müller