File: clique.gi

package info (click to toggle)
gap-hap 1.74%2Bds-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 58,664 kB
  • sloc: xml: 16,678; sh: 197; javascript: 155; makefile: 121; ansic: 47; perl: 24
file content (137 lines) | stat: -rw-r--r-- 3,624 bytes parent folder | download
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#######################################
#######################################
InstallGlobalFunction(SimplicialNerveOfTwoComplex,
function(K,dim)
local  A, Vertices, NrSimplices, Simplices, SimplicesLst, EnumeratedSimplex,
       bool, s, VL,x, y, d, i,j,k,l,m,n,RedundantFaces;

##########################
if not Dimension(K)<=2 then
Print("This function can only be applied to 2-dimensional simplicial complexes.\n");
return fail;
fi;
##########################


Vertices:=StructuralCopy(K!.vertices);
VL:=Length(Vertices);

SimplicesLst:=StructuralCopy(K!.simplicesLst);
Apply(SimplicesLst[3], x->SSortedList(x));
SimplicesLst[3]:=SSortedList(SimplicesLst[3]);


if dim>=3 then
SimplicesLst[4]:=[];
for s in SimplicesLst[3] do
i:=s[1];j:=s[2];k:=s[3];
for l in [k+1..VL] do
if 
SSortedList([i,j,l]) in SimplicesLst[3] and
SSortedList([i,l,k]) in SimplicesLst[3] and
SSortedList([l,j,k]) in SimplicesLst[3] 
then Add(SimplicesLst[4],SSortedList([i,j,k,l])); fi;
od;od;
SimplicesLst[4]:=SSortedList(SimplicesLst[4]);
if Length(SimplicesLst[4])=0 then dim:=2; fi;
fi;

if dim>=4 then
SimplicesLst[5]:=[];
for s in SimplicesLst[4] do
i:=s[1];j:=s[2];k:=s[3];l:=s[4];
for m in [l+1..VL] do
if
SSortedList([m,i,j]) in SimplicesLst[3] and
SSortedList([m,i,k]) in SimplicesLst[3] and
SSortedList([m,i,l]) in SimplicesLst[3] and
SSortedList([m,j,k]) in SimplicesLst[3] and
SSortedList([m,j,l]) in SimplicesLst[3] and
SSortedList([m,k,l]) in SimplicesLst[3] 
then Add(SimplicesLst[5],SSortedList([i,j,k,l,m])); fi;
od;od;
SimplicesLst[5]:=SSortedList(SimplicesLst[5]);
if Length(SimplicesLst[5])=0 then dim:=3; fi;
fi;

###########################GOT THIS FAR
if dim>=5 then
SimplicesLst[6]:=[];
for s in SimplicesLst[5] do
i:=s[1];j:=s[2];k:=s[3];l:=s[4];m:=s[5];
for n in [m+1..VL] do

if
SSortedList([n,i,j]) in SimplicesLst[3] and
SSortedList([n,i,k]) in SimplicesLst[3] and
SSortedList([n,i,l]) in SimplicesLst[3] and
SSortedList([n,i,m]) in SimplicesLst[3] and
SSortedList([n,j,k]) in SimplicesLst[3] and
SSortedList([n,j,l]) in SimplicesLst[3] and
SSortedList([n,j,m]) in SimplicesLst[3] and
SSortedList([n,k,l]) in SimplicesLst[3] and
SSortedList([n,k,m]) in SimplicesLst[3] and
SSortedList([n,l,m]) in SimplicesLst[3] 
then Add(SimplicesLst[6],SSortedList([i,j,k,l,m,n])); fi;
od;od;
SimplicesLst[6]:=SSortedList(SimplicesLst[6]);
if Length(SimplicesLst[6])=0 then dim:=4; fi;
fi;

if dim>=6 then Print("The function is only implemented up to dimension 5.\n");
return fail;
fi;

for d in [6..dim] do
SimplicesLst[d+1]:=[];
for y in Combinations(Vertices,d+1) do
bool:=true;
for x in Combinations(y,2) do
if A[x[1]][x[2]]=0 then bool:=false; break; fi;
od;
if bool then Add(SimplicesLst[d],y); fi;
od;
SimplicesLst[d+1]:=SSortedList(SimplicesLst[d+1]);
if Length(SimplicesLst[d+1])=0 then dim:=d-1; fi;
od;
##########################

##########################
Simplices:=function(d,k)
return SimplicesLst[d+1][k];
end;
#########################


##########################
NrSimplices:=function(d)
return Length(SimplicesLst[d+1]);
end;
#########################

#########################
EnumeratedSimplex:=function(v)
return PositionSet(SimplicesLst[Length(v)],v);
end;
#########################

Add(SimplicesLst,[]);

return
Objectify(HapSimplicialComplex,
           rec(
           vertices:=Vertices,
           nrSimplices:=NrSimplices,
           simplices:=Simplices,
           simplicesLst:=SimplicesLst,
           enumeratedSimplex:=EnumeratedSimplex,
           properties:=[
           ["dimension",dim]]
           ));



end);
#####################################################################