I have a graph stored as an adjacency list. The vertex property holds an int ID, and the edge property holds a 4x4 matrix and a weight;
In a test case, the graph is a 3-vertex graph with an edge connecting each pair of vertices (a complete graph).
I have a vector of edges descriptors PathType
, representing a path, and I am iterating through it and accessing each edge and its property, RelationshipEdge
, as follows.
for(PathType::iterator pathIterator = path.begin(); pathIterator != path.end(); ++pathIterator){
edge_t edge = *pathIterator;
RelationshipEdge rEdge = m_graph[edge];
int sourceID = m_graph[boost::source(edge, m_graph)].id;
int destID = m_graph[boost::target(edge, m_graph)].id;
However sometimes when this is performed, the RelationshipEdge
returned contains the data for the wrong edge.
As an example, inspecting edge
shows an m_source
of 1 and m_target
of 2. If I inspect the graph and find the edge with source 1 and target 2, the weight is 3 and the matrix is as entered. However rEdge has a weight of 1, and a different matrix. Those values actually correspond with the edge with source 0 and target 1.
Am I accessing the edge properties correctly?
The definition of my graph type is:
typedef boost::adjacency_list<
boost::vecS, boost::vecS, boost::undirectedS, MarkerVertex, RelationshipEdge>
CorrelationAdjacencyList;