-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathvertexGroup.cpp
43 lines (37 loc) · 920 Bytes
/
vertexGroup.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
#include "vertexGroup.h"
VertexGroup::VertexGroup(void)
{
cntVertex = 0;
isDeleted = new bool[Config::MAX_POINT_NUM];
for(int i = 0;i < Config::MAX_POINT_NUM;i++)
isDeleted[i] = false;
}
VertexGroup::~VertexGroup(void)
{
}
int VertexGroup::addVertex(Vertex p){
cntVertex++;
p.id = cntVertex;
group[cntVertex] = p;
return cntVertex;
}
void VertexGroup::delVertex(int _id){
if(_id >= Config::MAX_POINT_NUM){
return;
}
isDeleted[_id] = true;//从group中删除
//从邻接点中删除自己
for(set<int>::iterator it = group[_id].connectVertexes.begin();it != group[_id].connectVertexes.end();it++){
group[(*it)].delConnectVertex(_id);
}
}
int VertexGroup::getCommonVertexNum(int u,int v){
int cnt = 0;
for (set<int>::iterator it = group[u].connectVertexes.begin();
it != group[u].connectVertexes.end();it++){//在u的邻接点中遍历
if(group[v].isExistConnectVertex(*it)){
cnt++;
}
}
return cnt;
}