-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.h
60 lines (51 loc) · 1.2 KB
/
Graph.h
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef GRAPH_H
#define GRAPH_H
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <boost/multiprecision/gmp.hpp>
namespace Ron
{
using R = boost::multiprecision::mpq_rational;
class Vertex;
class Edge;
class Graph
{
public:
Graph() {};
~Graph() {};
void add_vertex (const std::string& name, const R& x, const R& y, const R& z);
void add_edge (const std::string& from, const std::string& to);
void read(const std::string& filename);
private:
std::unordered_map<std::string, Vertex*> vertices;
std::vector<Edge*> edges;
};
class Vertex
{
public:
Vertex(const std::string& label,const R& x, const R& y, const R& z) : label(label)
{
coord[0] = x;
coord[1] = y;
coord[2] = z;
}
void add_edge(Edge* e)
{
edges.push_back(e);
}
private:
R coord[3];
std::vector<Edge*> edges;
std::string label;
};
class Edge
{
public:
Edge(Vertex* p1, Vertex* p2) : p1(p1), p2(p2) {}
private:
Vertex *p1, *p2;
};
}
#endif // GRAPH_H