Skip to content

Commit 3de6ca2

Browse files
committed
fix: global_to_local asserts on edges not in the subgraph, mirroring the vertex overload
1 parent 3999385 commit 3de6ca2

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

include/boost/graph/subgraph.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,14 @@ template < typename Graph > class subgraph
207207

208208
vertex_descriptor global_to_local(vertex_descriptor u_global) const
209209
{
210-
vertex_descriptor u_local;
211-
bool in_subgraph;
212210
if (is_root())
213211
return u_global;
212+
vertex_descriptor u_local;
213+
bool in_subgraph;
214214
boost::tie(u_local, in_subgraph) = this->find_vertex(u_global);
215-
BOOST_ASSERT(in_subgraph == true);
215+
BOOST_ASSERT_MSG(in_subgraph,
216+
"global_to_local: vertex is not in this subgraph. "
217+
"Use find_vertex() to check membership first.");
216218
return u_local;
217219
}
218220

@@ -225,10 +227,15 @@ template < typename Graph > class subgraph
225227

226228
edge_descriptor global_to_local(edge_descriptor e_global) const
227229
{
228-
return is_root() ? e_global
229-
: (*m_local_edge.find(
230-
get(get(edge_index, root().m_graph), e_global)))
231-
.second;
230+
if (is_root())
231+
return e_global;
232+
edge_descriptor e_local;
233+
bool in_subgraph;
234+
boost::tie(e_local, in_subgraph) = this->find_edge(e_global);
235+
BOOST_ASSERT_MSG(in_subgraph,
236+
"global_to_local: edge is not in this subgraph. "
237+
"Use find_edge() to check membership first.");
238+
return e_local;
232239
}
233240

234241
// Is vertex u (of the root graph) contained in this subgraph?

0 commit comments

Comments
 (0)