-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMGraph.cpp
44 lines (43 loc) · 1.1 KB
/
MGraph.cpp
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
#include<iostream>
using namespace std;
typedef int VRType;//顶点关系类型1/0 x/oo
typedef int InfoType;//弧相关信息类型
typedef int VertexType;//顶点类型
#define MAX_VERTEX_NUM 20
typedef enum {DG,DN,UDG,UDN} GraphKind;
class ArcCell
{
public:
VRType adj;
InfoType * info;
};
typedef ArcCell AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
class MGraph
{
public:
int vexnum, arcnum;
MGraph(int vexnum,int arcnum){
this->vexnum=vexnum;
this->arcnum=arcnum;
}
void InitMGraph(VertexType vexs[],int** arcs) {
for(int i = 0; i < this->vexnum; i++) {
this->vexs[i]=vexs[i];
}
for(int i = 0; i < this->vexnum; i++) {
for(int j = 0; j < this->vexnum; j++) {
this->arcs[i][j].adj=arcs[i][j];
}
}
}
void InitMGraph(int** arcs) {
for(int i = 0; i < this->vexnum; i++) {
for(int j = 0; j < this->vexnum; j++) {
this->arcs[i][j].adj=arcs[i][j];
}
}
}
GraphKind kind;
AdjMatrix arcs;
VertexType vexs[MAX_VERTEX_NUM];
};