Commit 8237f35f authored by Tiago Peixoto's avatar Tiago Peixoto

Fix problem with all_neighbours_range() selector

parent 5a4ff166
......@@ -208,6 +208,15 @@ out_edges(typename graph_traits<undirected_adaptor<Graph>>::vertex_descriptor u,
return _all_edges_out(u, g.original_graph());
}
template <class Graph>
inline __attribute__((always_inline)) __attribute__((flatten))
auto
_all_edges_out(typename graph_traits<undirected_adaptor<Graph>>::vertex_descriptor u,
const undirected_adaptor<Graph>& g)
{
return out_edges(u, g);
}
//==============================================================================
// in_edges(u,g)
//==============================================================================
......
......@@ -432,6 +432,20 @@ in_neighbours(typename filt_graph<G, EP, VP>::vertex_descriptor u,
adjacency_iterator(range.second, const_cast<Graph*>(&g)));
}
template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename filt_graph<G, EP, VP>::adjacency_iterator,
typename filt_graph<G, EP, VP>::adjacency_iterator>
all_neighbours(typename filt_graph<G, EP, VP>::vertex_descriptor u,
const filt_graph<G, EP, VP>& g)
{
typedef filt_graph<G, EP, VP> Graph;
typedef typename Graph::adjacency_iterator adjacency_iterator;
auto range = _all_edges_out(u, g);
return std::make_pair(adjacency_iterator(range.first, const_cast<Graph*>(&g)),
adjacency_iterator(range.second, const_cast<Graph*>(&g)));
}
template <typename G, typename EP, typename VP>
inline __attribute__((always_inline)) __attribute__((flatten))
std::pair<typename filt_graph<G, EP, VP>::adjacency_iterator,
......
......@@ -209,6 +209,15 @@ in_neighbours(typename graph_traits<BidirectionalGraph>::vertex_descriptor u,
return out_neighbours(u, g._g);
}
template <class BidirectionalGraph, class GRef>
inline std::pair<typename reversed_graph<BidirectionalGraph,GRef>::adjacency_iterator,
typename reversed_graph<BidirectionalGraph,GRef>::adjacency_iterator>
all_neighbours(typename graph_traits<BidirectionalGraph>::vertex_descriptor u,
const reversed_graph<BidirectionalGraph,GRef>& g)
{
return all_neighbours(u, g._g);
}
template <class BidirectionalGraph, class GRef>
inline std::pair<typename reversed_graph<BidirectionalGraph,GRef>::adjacency_iterator,
typename reversed_graph<BidirectionalGraph,GRef>::adjacency_iterator>
......
......@@ -557,47 +557,6 @@ struct out_neighbour_iteratorS
}
};
// helper types for all_neighbours_iteratorS
template <class Graph, class IsDirected>
struct get_all_neighbours
{
BOOST_MPL_ASSERT((std::is_same<IsDirected,std::true_type>));
BOOST_MPL_ASSERT((std::is_convertible
<typename boost::graph_traits<Graph>::directed_category,
boost::directed_tag>));
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
typedef typename boost::graph_traits<boost::undirected_adaptor<Graph> >::adjacency_iterator
type;
inline __attribute__((always_inline))
static std::pair<type,type> get_neighbours(vertex_descriptor v,
const Graph& g)
{
using namespace boost;
const boost::undirected_adaptor<Graph> ug(g);
return out_neighbours(v, ug);
}
};
template <class Graph>
struct get_all_neighbours<Graph,std::false_type>
{
BOOST_MPL_ASSERT((std::is_convertible
<typename boost::graph_traits<Graph>::directed_category,
boost::undirected_tag>));
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
typedef typename boost::graph_traits<Graph>::out_neighbours_iterator type;
inline __attribute__((always_inline))
static std::pair<type,type> get_neighbours(vertex_descriptor v,
const Graph& g)
{
using namespace boost;
return out_neighbours(v, g);
}
};
// this "all neighbours" iterator selector returns the in-neighbours +
// out-neighbours ranges for directed graphs and the out-neighbours range for
// undirected graphs. The iterator type is given by
......@@ -605,31 +564,26 @@ struct get_all_neighbours<Graph,std::false_type>
template <class Graph>
struct all_neighbours_iteratorS
{
typedef typename boost::graph_traits<Graph>::directed_category
directed_category;
typedef typename std::is_convertible<directed_category,
boost::directed_tag>::type is_directed;
typedef typename get_all_edges<Graph,is_directed>::type type;
typedef typename boost::graph_traits<Graph>::adjacency_iterator type;
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
inline __attribute__((always_inline))
static std::pair<type,type> get_neighbours(vertex_descriptor v,
const Graph& g)
{
return get_all_neighbours<Graph,is_directed>::get_edges(v, g);
return all_neighbours(v, g);
}
};
// helper types for in_or_out_neighbours_iteratorS
template <class Graph, class IsDirected>
struct get_in_or_out_neighbours
: public get_in_neighbours<Graph,IsDirected>
: public in_neighbour_iteratorS<Graph>
{};
template <class Graph>
struct get_in_or_out_neighbours<Graph,std::false_type>
: public get_all_neighbours<Graph,std::false_type>
struct get_in_or_out_neighbours<Graph, std::false_type>
: public out_neighbour_iteratorS<Graph>
{};
// this "in or out" iterator selector returns the in-neighbour range for
......
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