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

Fix edge descriptor invalidation check

This fixes the edge invalidation check, when either the source of the
target vertex is removed.
parent 2e5abc00
...@@ -254,13 +254,21 @@ public: ...@@ -254,13 +254,21 @@ public:
bool IsValid() const bool IsValid() const
{ {
if (_g().ptr() == Py_None) if (_g().ptr() == Py_None || !_valid)
return false; return false;
GraphInterface& gi = python::extract<GraphInterface&>(_g().attr("_Graph__graph")); GraphInterface& gi = python::extract<GraphInterface&>(_g().attr("_Graph__graph"));
GraphInterface::edge_t e(_e); GraphInterface::edge_t e(_e);
return (_valid && bool valid = PythonVertex(_g, source(e, gi._state->_mg)).IsValid() &&
PythonVertex(_g, source(e, gi._state->_mg)).IsValid() && PythonVertex(_g, target(e, gi._state->_mg)).IsValid();
PythonVertex(_g, target(e, gi._state->_mg)).IsValid()); if (!valid)
return false;
valid = false;
graph_traits<GraphInterface::multigraph_t>::out_edge_iterator ei, ei_end;
for (tie(ei, ei_end) = out_edges(source(e, gi._state->_mg), gi._state->_mg);
ei != ei_end; ++ei)
if (*ei == e)
valid = true;
return valid;
} }
void SetValid(bool valid) void SetValid(bool valid)
......
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