Skip to content

Commit

Permalink
Merge pull request #269 from cqc-alec/bugfix/issue_268
Browse files Browse the repository at this point in the history
Revert commit change to `reindex_edge_list`

Specifically, this reverts 5dd7483.
  • Loading branch information
jeremy-murphy authored Feb 21, 2022
2 parents 31026c4 + 99d0414 commit fa3bd05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/boost/graph/detail/adjacency_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2069,15 +2069,20 @@ namespace detail
inline void reindex_edge_list(
EdgeList& el, vertex_descriptor u, boost::disallow_parallel_edge_tag)
{
for (typename EdgeList::iterator ei = el.begin(); ei != el.end(); ++ei)
typename EdgeList::iterator ei = el.begin(), e_end = el.end();
while (ei != e_end)
{
if (ei->get_target() > u)
{
typename EdgeList::value_type ce = *ei;
++ei;
el.erase(ce);
--ce.get_target();
el.insert(ce);
}
else {
++ei;
}
}
}
} // namespace detail
Expand Down
18 changes: 18 additions & 0 deletions test/delete_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,23 @@ int main(int argc, char* argv[])

BOOST_TEST(m_graph[ed1] == EDGE_VAL);

// https://github.com/boostorg/graph/issues/268
// 1. Undirected:
{
boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS> g;
boost::add_edge(2, 0, g);
boost::remove_vertex(1, g);
BOOST_TEST(num_vertices(g) == 2);
BOOST_TEST(num_edges(g) == 1);
}
// 2. Directed:
{
boost::adjacency_list<boost::setS, boost::vecS, boost::directedS> g;
boost::add_edge(2, 0, g);
boost::remove_vertex(1, g);
BOOST_TEST(num_vertices(g) == 2);
BOOST_TEST(num_edges(g) == 1);
}

return boost::report_errors();
}

0 comments on commit fa3bd05

Please sign in to comment.