On Thu, 1 Apr 2010, Trevor Harmon wrote:
On Apr 1, 2010, at 6:40 AM, Jeremiah Willcock wrote:
Note that you need to fill in the edge indices
Okay, so whenever I add an edge I need to assign it a unique index myself. Here's how I'm doing it for the initial construction of the graph:
size_t edgeIndex = 0; for (...) { Vertex u = ... Vertex v = ... Edge edge; bool inserted; tie(edge, inserted) = add_edge(u, v, g); EdgeIndexMap edgeIndexMap = get(edge_index, g); put(edgeIndexMap, edge, edgeIndex++); }
Does that look right? It seems to work, but I'm wondering if it's the best way.
That's fine, but you don't need to fetch edgeIndexMap every time -- you can get it outside the loop then use it repeatedly. You can also create the edges without filling in the edge indices then do a loop over edges(g) to fill them all in at once. -- Jeremiah Willcock