-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph_W.h
More file actions
65 lines (47 loc) · 916 Bytes
/
graph_W.h
File metadata and controls
65 lines (47 loc) · 916 Bytes
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
#ifndef GRAPH_H
#define GRAPH_H
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <fstream>
#define DIS_INF 2147483647
using namespace std;
class Node;
class Edge{
public:
Edge(Node *a, Node *b);
Node* node[2];
Node *getNeighbor(Node *n);
bool operator < (const Edge& rhs) const;
};
class Node{
public:
Node(const int& i);
void addEdge(Edge *e);
void sortEdge();
int id;
int color;
bool traveled;
vector<Edge *> edge;
int d;
Node *prev;
int heap_idx;
};
class Graph{
public:
Graph(const string& n);
~Graph();
void addEdge(const int& v1, const int& v2);
void sortEdgesOfNode();
void sortNodesByDegree();
void sortNodesByID();
void init();
Node * getNodeById(const int& id);
map<int, Node *> nodesMap;
vector<Node *> nodes;
vector<Edge *> edges;
string name;
};
#endif