Commit 5292b8ce authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix bug in remove_edge() in graph_wrap

parent ebccfe1e
...@@ -161,34 +161,38 @@ degree(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, ...@@ -161,34 +161,38 @@ degree(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
} }
template <class Graph> template <class Graph>
inline std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor, bool> inline std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor,
bool>
add_edge(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, add_edge(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v, typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v,
GraphWrap<Graph>& g) GraphWrap<Graph>& g)
{ {
std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor, bool> retval = std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor, bool>
add_edge(u, v, g._g); retval = add_edge(u, v, g._g);
g._gi.AddEdgeIndex(retval.first); g._gi.AddEdgeIndex(retval.first);
return retval; return retval;
} }
template <class Graph> template <class Graph>
inline void remove_edge(typename graph_traits<GraphWrap<Graph> >::edge_descriptor e, inline void remove_edge
GraphWrap<Graph>& g) (typename graph_traits<GraphWrap<Graph> >::edge_descriptor e,
GraphWrap<Graph>& g)
{ {
g._gi.RemoveEdgeIndex(e); g._gi.RemoveEdgeIndex(e);
} }
template <class Graph> template <class Graph>
inline void remove_edge(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, inline void remove_edge
typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v, (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
Graph& g) typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v,
Graph& g)
{ {
vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor> removed_edges; vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor>
removed_edges;
typename graph_traits<GraphWrap<Graph> >::out_edge_iterator e, e_end; typename graph_traits<GraphWrap<Graph> >::out_edge_iterator e, e_end;
for(tie(e, e_end) = out_edges(u, g); e != e_end; ++e) for(tie(e, e_end) = out_edges(u, g); e != e_end; ++e)
if (target(e, g) == v) if (target(*e, g) == v)
removed_edges.push_back(*e); removed_edges.push_back(*e);
for (typeof(removed_edges.begin()) iter = removed_edges.begin(); for (typeof(removed_edges.begin()) iter = removed_edges.begin();
iter != removed_edges.end(); ++iter) iter != removed_edges.end(); ++iter)
...@@ -204,8 +208,9 @@ add_vertex(GraphWrap<Graph>& g) ...@@ -204,8 +208,9 @@ add_vertex(GraphWrap<Graph>& g)
} }
template <class Graph> template <class Graph>
inline void clear_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, inline void clear_vertex
GraphWrap<Graph>& g) (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
GraphWrap<Graph>& g)
{ {
typedef GraphWrap<Graph> graph_t; typedef GraphWrap<Graph> graph_t;
vector<typename graph_traits<graph_t>::edge_descriptor> del_es; vector<typename graph_traits<graph_t>::edge_descriptor> del_es;
...@@ -224,8 +229,9 @@ inline void clear_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descri ...@@ -224,8 +229,9 @@ inline void clear_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descri
} }
template <class Graph> template <class Graph>
inline void remove_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, inline void remove_vertex
GraphWrap<Graph>& g) (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
GraphWrap<Graph>& g)
{ {
clear_vertex(u, g); clear_vertex(u, g);
remove_vertex(u, g._g); remove_vertex(u, g._g);
...@@ -233,10 +239,12 @@ inline void remove_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descr ...@@ -233,10 +239,12 @@ inline void remove_vertex(typename graph_traits<GraphWrap<Graph> >::vertex_descr
template <class Graph, class Predicate> template <class Graph, class Predicate>
inline void inline void
remove_out_edge_if(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, remove_out_edge_if
Predicate predicate, Graph& g) (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
Predicate predicate, Graph& g)
{ {
vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor> removed_edges; vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor>
removed_edges;
typename graph_traits<GraphWrap<Graph> >::out_edge_iterator e, e_end; typename graph_traits<GraphWrap<Graph> >::out_edge_iterator e, e_end;
for(tie(e, e_end) = out_edges(u, g); e != e_end; ++e) for(tie(e, e_end) = out_edges(u, g); e != e_end; ++e)
......
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