diff --git a/lib/graph/graph.hpp b/lib/graph/graph.hpp index e4e29f8..6e38cd8 100644 --- a/lib/graph/graph.hpp +++ b/lib/graph/graph.hpp @@ -165,7 +165,7 @@ inline std::vector::Edge> edges(const Graph& g) std::vector::Edge> retval; for (const auto& v : g.vertices()) for (const auto& e : g.neighboursOf(v)) - retval.push_back(typename Graph::Edge(v, e)); + retval.emplace_back(typename Graph::Edge(v, e)); return retval; } @@ -217,8 +217,7 @@ inline Graph::Graph(const std::vector& edge_list) template inline void Graph::addVertex(const_reference data) { - std::pair p(data, edge_container()); - m_vertices.insert(p); + m_vertices.emplace(data, edge_container()); } template @@ -244,10 +243,8 @@ inline void Graph::modifyVertex(const_reference old_data, const_reference new } const auto number_of_removed_elements = m_vertices.erase(old_data); - if (number_of_removed_elements > 0) { - std::pair p(new_data, neighbours); - m_vertices.insert(p); - } + if (number_of_removed_elements > 0) + m_vertices.emplace(new_data, neighbours); } template