20 #ifndef RIPPLE_PEERFINDER_SIM_GRAPHALGORITHMS_H_INCLUDED
21 #define RIPPLE_PEERFINDER_SIM_GRAPHALGORITHMS_H_INCLUDED
24 namespace PeerFinder {
27 template <
typename Vertex>
35 template <
typename Vertex,
typename Function>
39 using Edges =
typename Traits::Edges;
40 using Edge =
typename Traits::Edge;
47 work.emplace_back (&start, 0);
49 while (! work.empty ())
51 Probe
const p (work.front());
53 if (visited.find (p.first) != visited.end ())
55 diameter =
std::max (p.second, diameter);
56 visited.insert (p.first);
57 for (
typename Edges::iterator iter (
58 Traits::edges (*p.first).begin());
59 iter != Traits::edges (*p.first).end(); ++iter)
61 Vertex* v (Traits::vertex (*iter));
62 if (visited.find (v) != visited.end())
65 work.emplace_back (v, p.second + 1);
67 f (*p.first, diameter);