Commit 4a1b3817 authored by Tiago Peixoto's avatar Tiago Peixoto

Small fixes in GraphWrap

Use correct types and always pass GraphWrap objects by value.
parent dd981325
...@@ -192,6 +192,18 @@ void remove_edge(typename graph_traits ...@@ -192,6 +192,18 @@ void remove_edge(typename graph_traits
return remove_edge(e,const_cast<Graph&>(g.m_g)); return remove_edge(e,const_cast<Graph&>(g.m_g));
} }
//==============================================================================
//remove_edge(e, reverse_graph<G>)
//==============================================================================
template <class Graph>
inline
void remove_edge
(typename graph_traits<reverse_graph<Graph> >::edge_descriptor e,
reverse_graph<Graph>& g)
{
return remove_edge(e,const_cast<Graph&>(g.m_g));
}
//============================================================================== //==============================================================================
// add_vertex(filtered_graph<G>) // add_vertex(filtered_graph<G>)
//============================================================================== //==============================================================================
......
...@@ -40,6 +40,9 @@ class GraphWrap ...@@ -40,6 +40,9 @@ class GraphWrap
typedef typename Graph::graph_tag graph_tag; typedef typename Graph::graph_tag graph_tag;
typedef Graph orig_graph_t; typedef Graph orig_graph_t;
typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
Graph& _g; Graph& _g;
GraphInterface& _gi; GraphInterface& _gi;
}; };
...@@ -53,6 +56,10 @@ GraphWrap<Graph> graph_wrap(Graph& g, GraphInterface& gi) ...@@ -53,6 +56,10 @@ GraphWrap<Graph> graph_wrap(Graph& g, GraphInterface& gi)
template <class Graph> template <class Graph>
struct graph_traits<GraphWrap<Graph> >: public graph_traits<Graph> {}; struct graph_traits<GraphWrap<Graph> >: public graph_traits<Graph> {};
template <class Graph>
struct graph_traits<const GraphWrap<Graph> >:
public graph_traits<const Graph> {};
template <class Graph> template <class Graph>
inline typename graph_traits<GraphWrap<Graph> >::vertex_descriptor inline typename graph_traits<GraphWrap<Graph> >::vertex_descriptor
source(typename graph_traits<GraphWrap<Graph> >::edge_descriptor e, source(typename graph_traits<GraphWrap<Graph> >::edge_descriptor e,
...@@ -165,7 +172,7 @@ inline std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor, ...@@ -165,7 +172,7 @@ inline std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor,
bool> 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> std::pair<typename graph_traits<GraphWrap<Graph> >::edge_descriptor, bool>
retval = add_edge(u, v, g._g); retval = add_edge(u, v, g._g);
...@@ -176,7 +183,7 @@ add_edge(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, ...@@ -176,7 +183,7 @@ add_edge(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
template <class Graph> template <class Graph>
inline void remove_edge inline void remove_edge
(typename graph_traits<GraphWrap<Graph> >::edge_descriptor e, (typename graph_traits<GraphWrap<Graph> >::edge_descriptor e,
GraphWrap<Graph>& g) GraphWrap<Graph> g)
{ {
g._gi.RemoveEdgeIndex(e); g._gi.RemoveEdgeIndex(e);
} }
...@@ -185,7 +192,7 @@ template <class Graph> ...@@ -185,7 +192,7 @@ template <class Graph>
inline void remove_edge inline void remove_edge
(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v, typename graph_traits<GraphWrap<Graph> >::vertex_descriptor v,
Graph& g) GraphWrap<Graph> g)
{ {
vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor> vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor>
removed_edges; removed_edges;
...@@ -202,7 +209,7 @@ inline void remove_edge ...@@ -202,7 +209,7 @@ inline void remove_edge
template <class Graph> template <class Graph>
inline typename graph_traits<GraphWrap<Graph> >::vertex_descriptor inline typename graph_traits<GraphWrap<Graph> >::vertex_descriptor
add_vertex(GraphWrap<Graph>& g) add_vertex(GraphWrap<Graph> g)
{ {
return add_vertex(g._g); return add_vertex(g._g);
} }
...@@ -210,7 +217,7 @@ add_vertex(GraphWrap<Graph>& g) ...@@ -210,7 +217,7 @@ add_vertex(GraphWrap<Graph>& g)
template <class Graph> template <class Graph>
inline void clear_vertex inline void clear_vertex
(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
GraphWrap<Graph>& g) 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;
...@@ -231,7 +238,7 @@ inline void clear_vertex ...@@ -231,7 +238,7 @@ inline void clear_vertex
template <class Graph> template <class Graph>
inline void remove_vertex inline void remove_vertex
(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
GraphWrap<Graph>& g) GraphWrap<Graph> g)
{ {
clear_vertex(u, g); clear_vertex(u, g);
remove_vertex(u, g._g); remove_vertex(u, g._g);
...@@ -241,7 +248,7 @@ template <class Graph, class Predicate> ...@@ -241,7 +248,7 @@ template <class Graph, class Predicate>
inline void inline void
remove_out_edge_if remove_out_edge_if
(typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u, (typename graph_traits<GraphWrap<Graph> >::vertex_descriptor u,
Predicate predicate, Graph& g) Predicate predicate, GraphWrap<Graph> g)
{ {
vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor> vector<typename graph_traits<GraphWrap<Graph> >::edge_descriptor>
removed_edges; removed_edges;
......
Markdown is supported
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