-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph_yu.h
More file actions
82 lines (63 loc) · 1.38 KB
/
graph_yu.h
File metadata and controls
82 lines (63 loc) · 1.38 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef GRAPH_H
#define GRAPH_H
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <fstream>
#include <queue>
#define DIS_INF 2147483647
using namespace std;
//
class Shape;
class Graph;
extern Graph* graph_;
class Edge{
public:
Edge(Shape* a, Shape* b);
Shape* shape[2];
Shape*getNeighbor (Shape* s);
bool operator < (const Edge& rhs) const;
};
class Shape{
public:
Shape();
Shape(int index, int x0, int y0, int x1, int y1) : _id(index), _x0(x0), _y0(y0), _x1(x1), _y1(y1) {};
void addEdge(Edge *e);
void sortEdge();
bool traveled;
int color;
int _id;
string name;
vector<Edge*>edge;
int _x0;
int _y0;
int _x1;
int _y1;
};
class Graph{
public:
Graph(const string& n);
~Graph();
void addEdge(const int& v1, const int& v2);
void sortEdgesOfShape();
void sortShapesByDegree();
void sortShapesByID();
void init();
bool readFile( char* filename);
void DFS(Shape* v, ostream& outfile, int& counter);
void BFS(Shape* v, ostream& outfile, int& counter, queue<Shape*>& list);
void Color(Shape* v, queue<Shape*>& list);
void reset_travel();
Shape * getShapeById(const int& id);
map<int, Shape *> shapesMap;
vector<Shape*> shapes;
vector<Edge*> edges;
string name;
//parameter
int alpha;
int beta;
int omega;
};
#endif