The above example code introduces functions to gain additional information on points. boost::adjacent_vertices()
returns a pair of iterators that refer to points a point connects to. You call boost::out_edges()
if you want to access all outgoing lines from a point. boost::in_edges()
accesses all ingoing lines. With undirected lines, it doesn’t matter which of the two functions is called.
boost::target()
returns the end point of a line. The start point is returned with boost::source()
.
The code writes 1 and 3, the indexes of the top right and bottom left fields, to standard output twice. boost::adjacent_vertices()
, is called with topLeft and returns and displays the indexes of the top right and bottom left fields. topLeft is also passed to boost::out_edges()
to retrieve the outgoing lines. Because boost::target()
is called on every outgoing line with std::for_each()
, the indexes of the top right and bottom left fields are displayed twice.
Comments