So, as we see in the above example code, to add four points to the graph, the function boost::add_vertex()
has to be called four times.
boost::add_vertex()
is a free-standing function and not a member function of boost::adjacency_list
. You will find there are many free-standing functions in Boost.Graph that could have been implemented as member functions. Boost.Graph is designed to be more of a generic library than an object-oriented library.
boost::add_vertex()
adds a point to a graph. In graph theory, a point is called vertex, which explains the function name.
boost::add_vertex()
returns an object of type boost::adjacency_list::vertex_descriptor
. This object represents a newly added point in the graph. You can write the objects to standard output as shown in the example. The example displays :
The above example identifies points through positive integers. These numbers are indexes to a vector that is used internally in boost::adjacency_list
. It’s no surprise that boost::add_vertex()
returns 0, 1, 2, and 3 since every call adds another point to the vector.
Comments