diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-01-03 23:22:48 -0500 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-01-03 23:22:48 -0500 |
commit | c5289accb8a27ca2cce537019e5bd4f37fef157e (patch) | |
tree | 18e301f930c9c6d61a0a469bb3dbf87651e20ac5 | |
parent | 57deb3c316dc4d9412251d51625a341c7bfbc284 (diff) |
Add get_vertices
-rw-r--r-- | src/graph.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/graph.h b/src/graph.h index 9df4b9f..8c04606 100644 --- a/src/graph.h +++ b/src/graph.h @@ -16,6 +16,17 @@ public: graph_[from].push_back(to); } + std::set<int> get_vertices() { + std::set<int> vertices; + + for (auto vertex : graph_) { + vertices.insert(vertex.first); + } + + return vertices; + } + + std::vector<int> const& get_neighbors(int vertex) { return graph_[vertex]; } |