-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.h
executable file
·50 lines (37 loc) · 952 Bytes
/
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
#ifndef GRAPH_H
#define GRAPH_H
#include <set>
// tags for file format
#define TAG_START "START"
#define TAG_END "END"
#define TAG_VERTICES "vertices"
#define TAG_EDGES "edges"
extern bool DEBUG; // from Main.cpp
// define a vertex as a int
typedef int Vertex;
// define the edge data structure
struct Edge
{
Vertex start, end;
int cost;
};
// necessary for set
inline bool operator<(const Edge& lhs, const Edge& rhs)
{
return lhs.start < rhs.start || lhs.end < rhs.end;
}
class Graph
{
private:
Graph(const std::set<Vertex>,const std::set<Edge>); // private constructor
public:
const std::set<Vertex> vertices;
const std::set<Edge> edges;
// constructs a Graph based on the given file
static Graph* constructFromFile(const char* fileName);
// check if the graph is valid
const bool isValid() const;
// returns the size of the graph
const int size() const;
};
#endif // GRAPH_H