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

Push is_adjacent() to graph_util.hh

parent 3721923c
......@@ -86,17 +86,6 @@ void print_update(size_t current, stringstream& str)
cout << str.str() << flush;
}
template <class Graph>
bool is_adjacent(typename graph_traits<Graph>::vertex_descriptor u,
typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g)
{
typename graph_traits<Graph>::adjacency_iterator a, a_end;
for (tie(a, a_end) = adjacent_vertices(u, g); a != a_end; ++a)
if (*a == v)
return true;
return false;
}
//
// Generation strategies
......
......@@ -39,21 +39,6 @@ namespace graph_tool
using namespace std;
using namespace boost;
// returns true if vertices u and v are adjacent. This is O(k(u)).
template <class Graph>
bool is_adjacent(typename graph_traits<Graph>::vertex_descriptor u,
typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g )
{
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e, e_end) = out_edges(u, g); e != e_end; ++e)
{
if (target(*e,g) == v)
return true;
}
return false;
}
template <class Graph>
typename graph_traits<Graph>::vertex_descriptor
source(const pair<size_t, bool>& e,
......
......@@ -107,6 +107,21 @@ struct SoftNumEdges
size_t operator()(Graph& g) const { return num_edges(g); }
};
// returns true if vertices u and v are adjacent. This is O(k(u)).
template <class Graph>
bool is_adjacent(typename graph_traits<Graph>::vertex_descriptor u,
typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g )
{
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e, e_end) = out_edges(u, g); e != e_end; ++e)
{
if (target(*e,g) == v)
return true;
}
return false;
}
// computes the out-degree of a graph, ignoring self-edges
template <class Graph>
inline size_t
......
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