Commit 52a48622 authored by Tiago Peixoto's avatar Tiago Peixoto

graph_adjacency.hh: slightly speedup edge removal

parent 2de7ad34
...@@ -1034,19 +1034,18 @@ void remove_edge(const typename adj_list<Vertex>::edge_descriptor& e, ...@@ -1034,19 +1034,18 @@ void remove_edge(const typename adj_list<Vertex>::edge_descriptor& e,
if (!g._keep_epos) // O(k_s + k_t) if (!g._keep_epos) // O(k_s + k_t)
{ {
// remove and shift // remove and shift
auto remove_e = [&] (auto& elist, auto&& begin, auto&& end, auto v) auto remove_e = [&] (auto& elist, auto&& begin, auto&& end)
{ {
auto iter = std::find_if(begin, end, auto iter = std::find_if(begin, end,
[&] (const auto& ei) -> bool [&] (const auto& ei) -> bool
{ return v == ei.first && { return idx == ei.second; });
idx == ei.second; });
assert(iter != end); assert(iter != end);
elist.erase(iter); elist.erase(iter);
}; };
remove_e(s_es, s_es.begin(), s_es.begin() + s_pos, t); remove_e(s_es, s_es.begin(), s_es.begin() + s_pos);
s_pos--; s_pos--;
remove_e(t_es, t_es.begin() + t_pos, t_es.end(), s); remove_e(t_es, t_es.begin() + t_pos, t_es.end());
} }
else // O(1) else // O(1)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment