[graph] dfs depending on VertexList container

Hi, We can't use the easiest syntax of dfs, if we use another container than vecS as VertexList container. boost::depth_first_search( graph, boost::visitor( vis ) ); So the only way is to initialize the colormap ourself and give it to the depth_first_search function. The problem is that the dfs use operator[]. I looked at the code and if I understand correctly, it seems that this operator is only use to init the colormap. Best regards, Fabien Castan

On Wed, 8 Sep 2010, fabien.castan@free.fr wrote:
Hi,
We can't use the easiest syntax of dfs, if we use another container than vecS as VertexList container. boost::depth_first_search( graph, boost::visitor( vis ) ); So the only way is to initialize the colormap ourself and give it to the depth_first_search function.
The problem is that the dfs use operator[]. I looked at the code and if I understand correctly, it seems that this operator is only use to init the colormap.
Does DFS itself use operator[]? I do not see that in the code. If your graph has a vertex_index_map property map (filled in appropriately), the algorithm should create the color map automatically from that. You can also just create your own color map and have it as a named argument to depth_first_search (that is simpler syntax than needing to write out all of the positional arguments). -- Jeremiah Willcock

Does DFS itself use operator[]? I do not see that in the code. If you compile the main.cpp attached in my first mail, you can see the error:
boost/graph/depth_first_search.hpp +197 put(color, u, Color::white()); boost/property_map/property_map.hpp +361 in function put: static_cast<const PropertyMap&>(pa)[k] = v; boost/property_map/shared_array_property_map.hpp:36: error: no match for 'operator[]'
If your graph has a vertex_index_map property map (filled in appropriately), the algorithm should create the color map automatically from that. You can also just create your own color map and have it as a named argument to depth_first_search (that is simpler syntax than needing to write out all of the positional arguments). Yes, I create my own colormap so that works in all cases. In my case I use the bundle properties, so there is an automatic vertex_index_map, isn't it ? But I find strange that a dfs don't works directly with all containers and especially if it's only to initialize the colormap...

On Thu, 9 Sep 2010, fabien wrote:
Does DFS itself use operator[]? I do not see that in the code. If you compile the main.cpp attached in my first mail, you can see the error:
boost/graph/depth_first_search.hpp +197 put(color, u, Color::white());
boost/property_map/property_map.hpp +361 in function put: static_cast<const PropertyMap&>(pa)[k] = v;
boost/property_map/shared_array_property_map.hpp:36: error: no match for 'operator[]'
Could you please send your full error trace? It also appears that you are not passing in your color map in main.cpp; it might still be trying to create one and complaining that it doesn't have a vertex_index map. If the type of "k" in the property_map.hpp line in the error message is something like void*, that would indicate a vertex_index map problem.
If your graph has a vertex_index_map property map (filled in appropriately), the algorithm should create the color map automatically from that. You can also just create your own color map and have it as a named argument to depth_first_search (that is simpler syntax than needing to write out all of the positional arguments).
Yes, I create my own colormap so that works in all cases. In my case I use the bundle properties, so there is an automatic vertex_index_map, isn't it ? But I find strange that a dfs don't works directly with all containers and especially if it's only to initialize the colormap...
It's not just to initialize the color map, but to use it during the algorithm as well. -- Jeremiah Willcock
participants (3)
-
fabien
-
fabien.castan@free.fr
-
Jeremiah Willcock