
Can someone help me with the following program? It crashes with Boost 1.33.1 on gcc34 (GCC) 3.4.3 20050113 (Red Hat 3.4.3-16): $ ./1 make_map_as_colormap entered writing something to MapAsColorMap Speicherzugriffsfehler I have tracked down the crash to this line in <boost/graph/breadth_first_search.hpp>: for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { But I don't know what happens there ... I'm quite sure the bug is NOT in my color map proxy ... Thanks a lot in advance! Cheers, Jens // //======================================================================= // Copyright 2007 University of Karlsruhe // Author: Jens Mueller // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= // #ifndef BFS_DISTMAP_8737 #define BFS_DISTMAP_8737 /* Use distance map (or anything else which suits the following requirements) as a color map. Write operations are just ignored. Read operations work as follows: When the value in the underlying map equals a specified value, e.g. -1 in a distance map, or the null pointer in a predecessor map, the 'White' value is returned, otherwise the 'Black' value is returned. Note: This only is usable for application where there is no need to distinguish gray and black non-tree edge targets. Note: Setting the value in the underlying map so that it no longer corresponds to a 'White' value will have to be done by the visitor on the discover_vertex event. */ /* Template parameters: - ColorValue (default value used by helper function: default_color_type) - ReadablePropertyMap (underlying map) */ /* Runtime parameters: - ReadablePropertyMap pm - ReadablePropertyMap::value_type white (must be == comparable) */ #include <boost/property_map.hpp> #include <iostream> template<typename ReadablePropertyMap, typename ColorValue> class MapAsColorMap { private: typename boost::property_traits<ReadablePropertyMap>::value_type white_; const ReadablePropertyMap& pm_; public: typedef typename boost::property_traits<ReadablePropertyMap>::key_type key_type; typedef ColorValue value_type; typedef ColorValue reference; typedef boost::read_write_property_map_tag category; ColorValue get(key_type key); MapAsColorMap(const ReadablePropertyMap& pm, typename boost::property_traits<ReadablePropertyMap>::value_type white): white_(white), pm_(pm) { /* nothing */ }; }; template<typename ReadablePropertyMap> MapAsColorMap<ReadablePropertyMap, boost::default_color_type> make_map_as_colormap(const ReadablePropertyMap& pm, typename boost::property_traits<ReadablePropertyMap>::value_type white) { std::cout << "make_map_as_colormap entered" << std::endl; return MapAsColorMap<ReadablePropertyMap, boost::default_color_type>(pm, white); } template<typename ReadablePropertyMap, typename ColorValue> ColorValue MapAsColorMap<ReadablePropertyMap, ColorValue>::get(key_type key) { std::cout << "get entered" << std::endl; std::cout << key << " " << boost::get(pm_, key) << std::endl; return (boost::get(pm_, key)==white_) ? boost::color_traits<ColorValue>::white() : boost::color_traits<ColorValue>::black(); } template<typename ReadablePropertyMap, typename ColorValue> ColorValue get(MapAsColorMap<ReadablePropertyMap, ColorValue> pmap, typename boost::property_traits<ReadablePropertyMap>::key_type key) { return pmap.get(key); } template<typename ReadablePropertyMap, typename ColorValue> void put(MapAsColorMap<ReadablePropertyMap, ColorValue> pmap, typename boost::property_traits<ReadablePropertyMap>::key_type key, typename boost::property_traits<ReadablePropertyMap>::value_type value) { std::cout << "writing something to MapAsColorMap" << std::endl; /* nothing */ } #endif

First you initialize Graph g; Afterward you initialize: Graph G(5); //add some vertices and edges And then you start to work with empty Graph g ;) Sure it will not work! If you simply remove Graph g; compiler will point you what to fix ;) With Kind Regards, Ovanes Markarian On Mon, February 19, 2007 19:36, Jens Müller wrote:
Can someone help me with the following program? It crashes with Boost 1.33.1 on gcc34 (GCC) 3.4.3 20050113 (Red Hat 3.4.3-16):
$ ./1 make_map_as_colormap entered writing something to MapAsColorMap Speicherzugriffsfehler
I have tracked down the crash to this line in <boost/graph/breadth_first_search.hpp>:
for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) {
But I don't know what happens there ...
I'm quite sure the bug is NOT in my color map proxy ...
Thanks a lot in advance!
Cheers,
Jens _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Ovanes Markarian schrieb:
First you initialize
Graph g;
Afterward you initialize:
Graph G(5); //add some vertices and edges
And then you start to work with empty Graph g ;) Sure it will not work!
If you simply remove
Graph g;
compiler will point you what to fix ;)
Sure :-) Thanks a lot! Damn tunnel vision ... Jens

I was able to compile and run your example and had some cmd line output. -----Original Message----- From: Jens Müller [mailto:jens.mueller@ira.uka.de] Sent: Montag, 19. Februar 2007 20:35 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [graph] Crash in breadth_first_search Jens Müller schrieb:
Sure :-)
Thanks a lot! Damn tunnel vision ...
Well, but it crashes when I use a graph read with the GraphML reader from graph-tools ... And, what wonder: The graph is empty ... OK ... I'll have to ask on the graph-tools about this ... _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Ovanes Markarian schrieb:
I was able to compile and run your example and had some cmd line output.
The exact version I posted here? Yeah, that works. What doesn't work is the GraphML reader - I posted an example on the graph-tool mailing list, available at Gmane as gmane.comp.science.graph.graph-tool.general, if you want to give it a try ... This reader does not seem to write anything to my graph - it takes some time to read the file, though, and doesn't produce any error messages ...

Jens Müller <jens.mueller@ira.uka.de> writes:
Jens Müller schrieb:
Sure :-)
Thanks a lot! Damn tunnel vision ...
Well, but it crashes when I use a graph read with the GraphML reader from graph-tools ...
And, what wonder: The graph is empty ... OK ... I'll have to ask on the graph-tools about this ...
Well, I'm not sure. Should BFS crash when used on an empty graph? -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams wrote:
Well, I'm not sure. Should BFS crash when used on an empty graph?
Well - I also passed it an invalid vertex descriptor: *vertices(g).first, which was in that case equal to *vertices(g).second ... It then crashed when BFS tried to get the out edge iterator ...
participants (3)
-
David Abrahams
-
Jens Müller
-
Ovanes Markarian