Commit 83087948 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Speed up removal of edges

An attempt no longer is made to reuse edge indexes in a contiguous
fashion.
parent edb9e873
......@@ -231,26 +231,7 @@ void remove_edge(GraphInterface& gi, const python::object& e)
void GraphInterface::RemoveEdgeIndex(const edge_t& e)
{
size_t index = _edge_index[e];
if (index == _state->_max_edge_index)
{
if (_state->_max_edge_index > 0)
_state->_max_edge_index--;
while (!_state->_free_indexes.empty() &&
_state->_max_edge_index == _state->_free_indexes.back())
{
_state->_free_indexes.pop_back();
if (_state->_max_edge_index > 0)
_state->_max_edge_index--;
}
}
else
{
typeof(_state->_free_indexes.begin()) pos =
lower_bound(_state->_free_indexes.begin(),
_state->_free_indexes.end(), index);
_state->_free_indexes.insert(pos, index);
}
_state->_free_indexes.push_back(index);
_state->_nedges--;
remove_edge(e, _state->_mg);
}
......
Supports Markdown
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