diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-01-03 22:37:27 -0500 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-01-03 22:37:27 -0500 |
commit | 4cd91c194dc93197ea972cfbd792f7acd81025d1 (patch) | |
tree | 038df6495e07d28ed2f67195a12ba21389dc7375 /src | |
parent | 1642694926ecdeb58869a46f9b5215170653b521 (diff) |
Implement graph
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/graph.h b/src/graph.h new file mode 100644 index 0000000..9df4b9f --- /dev/null +++ b/src/graph.h @@ -0,0 +1,26 @@ +#ifndef GRAPH_H +#define GRAPH_H + +#include <map> +#include <vector> + +class Graph { +public: + Graph() : graph_() {} + + void add_vertex(int vertex) { + graph_[vertex] = std::vector<int>(); + } + + void add_edge(int from, int to) { + graph_[from].push_back(to); + } + + std::vector<int> const& get_neighbors(int vertex) { + return graph_[vertex]; + } +private: + std::map<int, std::vector<int>> graph_; +}; + +#endif |