I have the following undirected BGL graph description:
typedef boost::adjacency_list<boost::setS, boost::listS, boost::undirectedS, VProp, EProp> Graph;
And in my code I'm using the following loop to access the out-edges of a given node v:
OutEdgeIter out_i;
OutEdgeIter out_end;
for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i)
{
Edge curEdge = *out_i;
Vertex curNeighbor = boost::target(curEdge, g);
// Other stuff here.
}
I'm noticing that any node v I get the out-edges of in this way has a peculiar property: the target of that node will always be the neighbor of v, and the source will always be v itself. This of course makes sense in the case of a directed graph, but my graph is undirected as mentioned previously. It's unclear (just from a definition perspective) what the source of target of an undirected edge is.
Is the above a documented, guaranteed property of BGL? I've written a few unit tests that depend on this property and they all pass, but it bugs me that I can't find this in the BGL docs (or perhaps I am just very bad at reading them).
(As an aside, it also appears that the "direction" of the edge does not matter when setting edge properties. Setting the weight of (u, v) to five causes the weight of boost::edge(v, u, g) to also return five: it still appears that there is only one underlying edge object.)