BGL: How to get add_edge work with adjacency_list graph

Dear List,
i just started learning about The Boost Graph Library. Here is my
Problem in a minimal example:
#include <iostream>
#include

On Mon, 26 Sep 2011, Christoph wrote:
Dear List,
i just started learning about The Boost Graph Library. Here is my Problem in a minimal example:
#include <iostream> #include
typedef boost::adjacency_list < boost::listS, boost::listS, boost::bidirectionalS> Map; int main() { Map map; std::cout << "number of vertices: " << num_vertices(map) << std::endl; Map::vertex_descriptor u = boost::add_vertex (map);; Map::vertex_descriptor v = boost::add_vertex (map);; std::cout << "number of vertices: " << num_vertices(map) << std::endl;
Map::add_edge (u, v, map); // <- problem return 0; }
The compiler tells me that ‘add_edge’ is not a member of ‘Map’. I would like to know why and what am i doing wrong by writing "Map::add_edge (u, v, map);"
The add_edge() function should be called unqualified; the compiler will find the correct definition. In particular, it is not a member of any class (static or non-static). -- Jeremiah Willcock

The add_edge() function should be called unqualified; the compiler will find the correct definition. In particular, it is not a member of any class (static or non-static).
Thank you very much for your answer. When i replace "Map::add_edge(u, v, map)" by "boost::add_edge(u, v, map)" it works fine. best regards Christoph

On Mon, 26 Sep 2011, Christoph wrote:
The add_edge() function should be called unqualified; the compiler will find the correct definition. In particular, it is not a member of any class (static or non-static).
Thank you very much for your answer. When i replace
"Map::add_edge(u, v, map)"
by
"boost::add_edge(u, v, map)"
it works fine.
You should really use "add_edge(u, v, map)" in case that function is moved to a different namespace in the future (or for user-defined graph types that are not in the boost namespace, if you care about those). -- Jeremiah Willcock

You should really use "add_edge(u, v, map)" in case that function is moved to a different namespace in the future (or for user-defined graph types that are not in the boost namespace, if you care about those).
Thank you for the advice. Could you please give me a reference to the docs to find out more about such general graph functions. For now i know "add_edge()" and "add_vertex()". Where are this functions defined? I am not quite familiar with generic programming yet. This may be one source of problems. Nevertheless, if the compiler finds the (template) function "add_edge()". Why does the compiler know where to look for the function "add_edge()". best regards Christoph

Thank you for the advice. Could you please give me a reference to the docs to find out more about such general graph functions. For now i know "add_edge()" and "add_vertex()".
Where are this functions defined? I am not quite familiar with generic programming yet. This may be one source of problems. Nevertheless, if the compiler finds the (template) function "add_edge()". Why does the compiler know where to look for the function "add_edge()".
I found "2.6.2 Koenig Lookup - Graph Operations" from the Book "The Boost Graph Library". I think this explains my questions. Thank you very much for your support! Christoph
participants (2)
-
Christoph
-
Jeremiah Willcock