blob: 9df4b9f3f94f17a3dca124ba7b521cb17cce77db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
|