I have an undirected adjacency_list
graph defined as this:
typedef boost::adjacency_list<
boost::vecS,
boost::vecS, boost::undirectedS,
boost::no_property,
boost::property<
boost::edge_weight_t, int, EdgeInfo>
> weighted_graph;
For my algorithms class, my program was too slow and only passed one of four test sets in terms of speed. I then did one small change that made my program pass all the time limit tests: I stopped using weightmap[boost::edge(u, v, G).first]
.
Instead I looped over all edges once, and stored each edge weight twice in a 2D Vector, so that I could look it up with weightvec[u][v]
instead.
I was not able to find any documentation on the runtime complexity of boost::edge()
. I expected it to be constant, but it seems like that's not true. What is the complexity in terms of number of edges and vertices in the graph?
I considered if it might be due to the access to the weight property map instead, but if I still use the weightmap and store the edge descriptors, I still see that speedup.