-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrounded.cpp
More file actions
74 lines (60 loc) · 1.56 KB
/
grounded.cpp
File metadata and controls
74 lines (60 loc) · 1.56 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
/*
* grounded.cpp
*
* Created on: 15/lug/2013
* Author: ilariamartinelli
*/
#include "grounded.h"
/**
* @brief get the subset of Arguments of C which are not attacked by Arguments in I
* @retval the resulting subset
*/
SetArguments get_not_attacked_nodes(SetArguments C, SetArguments I){
SetArguments N, intersect, result;
SetArguments * attacks;
C.clone(&N);
for (SetArgumentsIterator it = I.begin(); it != I.end(); it++){
attacks=(*it)->get_attacks();
for (SetArgumentsIterator jt = attacks->begin(); jt != attacks->end(); jt++){
if (N.exists((*jt)))
N.remove((*jt));
}
if(N.empty()) break;
}
return N;
}
/**
* @brief get the subset of Arguments of set which are attacked by Arguments in N
* @retval the resulting subset
*/
SetArguments get_attacked_from(SetArguments set, SetArguments N){
SetArguments intersect,result,tmp;
SetArguments * attacks;
for(SetArgumentsIterator it=N.begin();it!=N.end();it++){
attacks=(*it)->get_attacks();
tmp.setunion(attacks,&tmp);
}
tmp.intersect(&set,&result);
return result;
}
/**
* @brief first call I = A
*/
void grounded(SetArguments C, SetArguments *e, SetArguments *I) {
SetArguments N,ANC,ANI,temp;
*e = SetArguments();
int iter=0;
N=get_not_attacked_nodes(C, *I);
while(!N.empty()){
e->setunion(&N,e);
ANC=get_attacked_from(C,N);
ANI=get_attacked_from(*I,N);
N.setunion(&ANC,&temp);
C.setminus(&temp,&C);
N.setunion(&ANI,&temp);
I->setminus(&temp,I);
N=get_not_attacked_nodes(C, *I);
//cout<<"e: "<<*e<<endl;
//cout<<"I: "<<*I<<endl;
}
}