diff --git a/graph.hpp b/graph.hpp index 3e018b1..8638a9c 100644 --- a/graph.hpp +++ b/graph.hpp @@ -3,13 +3,12 @@ #include #include +#include + #include #include -// directed, weighted -/// @todo weight type as param too? - template class Graph { @@ -486,9 +485,11 @@ std::vector::pointer> Graph::neighboursOf(const_refer if (vertex_it == m_vertices.end()) return retval; + std::set tmp; std::for_each((*vertex_it).m_edges.begin(), (*vertex_it).m_edges.end(), - [&retval](const EdgeTo& e) - { retval.push_back(e.m_destination); }); /// @todo unique push! + [&tmp, &retval](const EdgeTo& e) + { if (tmp.insert(e.m_destination).second) + retval.push_back(e.m_destination); }); return retval; }