-
Notifications
You must be signed in to change notification settings - Fork 28
/
graph.h
96 lines (74 loc) · 1.95 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef GRAPH_H
#define GRAPH_H
#include <list>
#include <unordered_map>
namespace snu {
class Graph; // graph interface
class DSGraph; // directed simple graph
//class DMGraph; // directed multi graph
class USGraph; // undirected simple graph
//class UMGraph; // undirected multi graph
// simple: no multiple edges
class Graph {
protected:
typedef int VId; // vertex id
typedef int EId; // edge id
typedef int VLbl; // vertex label
typedef int ELbl; // edge label
typedef int Wgt; // integer type weight
typedef int Lblc; // label count
//typedef long long LWgt; // long long type weight
//typedef double DWgt; // double type weight
class Vertex;
class Edge;
class Vertex_Label;
class Edge_Label;
//class IEdge;
//class LEdge;
//class DEdge;
class Vertex {
private:
VId id;
std::list <Vertex_Label *> labels;
std::list <Edge *> edges;
};
class Edge {
private:
EId id;
std::list <Edge_Label *> labels;
Vertex * from;
Vertex * to;
};
class Vertex_Label {
private:
VLbl label;
std::list <Vertex *> vertices;
};
class Edge_Label {
private:
ELbl label;
std::list <Edge *> edges;
};
std::unordered_map <VId, Vertex *> id_to_vertex;
std::unordered_map <EId, Edge *> id_to_edge;
std::unordered_map <VLbl, Vertex_Label *> vertex_label_table;
std::unordered_map <ELbl, Edge_Label *> edge_label_table;
//std::unordered_map <std::pair <VId, VId>, Edge *> id_pair_to_edge;
public:
Graph(); // constructor
~Graph(); // destructor
void add_vertex(VId id, Lblc num, VLbl lbl[]); // add vertex
void add_edge(EId id, Lblc num, ELbl lbl[], VId from, VId to, Wgt weight); // add edge
// friend function
friend int * basicstat(Graph graph, int stat[]);
};
/*class DSGraph: public Graph { // directed simple graph
};*/
/*class DMGraph: public Graph {
};*/
/*class USGraph: public Graph {
};*/
/*class UMGraph: public Graph {
};*/
}
#endif // GRAPH_H