File: cayley.gi

package info (click to toggle)
gap-hap 1.66%2Bds-1
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 55,348 kB
  • sloc: xml: 15,368; sh: 216; javascript: 155; makefile: 126; ansic: 57; perl: 36
file content (110 lines) | stat: -rw-r--r-- 2,640 bytes parent folder | download | duplicates (3)
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
#(C) Graham Ellis 2005-2006

#################################################
InstallGlobalFunction(CayleyGraphOfGroup,
function(G,A)
local M, g, h, Elts;

M:=IdentityMat(Order(G))*0;
Elts:=Elements(G);

for g in [1..Order(G)] do
for h in [1..Order(G)] do
if Elts[g]*Elts[h]^-1 in A then M[g][h]:=1; fi;
if Elts[h]*Elts[g]^-1 in A then M[g][h]:=1; fi;

od;
od;

return IncidenceMatrixToGraph(M);

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


#####################################################################
InstallGlobalFunction(CayleyGraphOfGroupDisplay,
function(arg)
local G,X,Elts,M,i,j,COLOURS,tmpDir,tmpInlog,tmpIngif,tmpIn2log,
AppendTo, PrintTo;

AppendTo:=HAP_AppendTo;
PrintTo:=HAP_PrintTo;

tmpDir:=DirectoryTemporary();

tmpInlog:=Filename(tmpDir,"tmpIn.log");
tmpIngif:=Filename(tmpDir,"tmpIn.gif");
tmpIn2log:=Filename(tmpDir,"tmpIn2.log");


COLOURS:=["blue","red","green","yellow","brown","black"];

G:=arg[1];
X:=arg[2];
if IsGroup(G) then
	Elts:=Elements(G);
	else
	Elts:=G;
fi;

if Length(X)>6 then
Print("There are too many generators.\n");
return fail;
fi;



M:=List([1..Length(Elts)],i->[]);

for i in [1..Length(Elts)] do
for j in [1..Length(Elts)] do
M[i][j]:=Position(X,Elts[i]^-1*Elts[j]);
od;
od;

################ WRITE TO TMPIN.LOG #################################

AppendTo(tmpInlog," graph G { \n size=\"4,4\" \n subgraph cluster0 {\n node [shape=ellipse, width=.2,height=.2,fixedsize=true,style=filled, color=gray35,label=\"\"] \n edge [style=\"setlinewidth(2)\"] \n");

for i in [1..Length(Elts)] do
for j in [1..Length(Elts)] do

if  M[i][j]=fail then
AppendTo(tmpInlog,i, " \n");
else
AppendTo(tmpInlog,i," -- ", j, "[color=",COLOURS[M[i][j]],"] \n");
fi;

od;od;

AppendTo(tmpInlog," }\n subgraph cluster1 {\n  node [shape=box, width=2,height=1,fixedsize=true,style=filled, color=white,fillcolor=white] \n ");

if Maximum(List(X,x->Length(String(x))))<20 then
for i in [1..Length(X)] do
AppendTo(tmpInlog,-i,"  [fontcolor= ",COLOURS[i],",label=\"", X[i],"\" ] \n");
od;
fi;


AppendTo(tmpInlog,"}\n }\n");
############### WRITTEN ############################################
Exec(Concatenation(NEATO_PATH,"-Tgif ", tmpInlog," > ", tmpIngif));

if Length(arg)=2 then
Exec(Concatenation(DISPLAY_PATH, tmpIngif));
Exec(Concatenation("rm ",tmpInlog,"; rm ",tmpIngif));

else

AppendTo(tmpIn2log, "Browser=",arg[3],"\n");
AppendTo(tmpIn2log,"$Browser ", tmpIngif);
Exec(Concatenation("chmod a+x ",tmpIn2log," ; ", tmpIn2log));
Exec(Concatenation("rm ",tmpInlog," ; rm ",tmpIngif,"; rm ",tmpIn2log,";"));
fi;


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