m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-01-03 22:37:27 -0500
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-01-03 22:37:27 -0500
commit4cd91c194dc93197ea972cfbd792f7acd81025d1 (patch)
tree038df6495e07d28ed2f67195a12ba21389dc7375
parent1642694926ecdeb58869a46f9b5215170653b521 (diff)
Implement graph
-rw-r--r--src/graph.h26
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