File: graphs.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 (134 lines) | stat: -rw-r--r-- 3,868 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
#(C) 2005-2006 Graham Ellis

#A:=Group([(1,2),(1,2,3,4,5)]);SetName(A,"S5");
#B:=Group([(1,2),(1,2,3,4)]);SetName(B,"S4");
#C:=SymmetricGroup(3);SetName(C,"S3");
#CA:=GroupHomomorphismByFunction(C,A,x->x);
#CB:=GroupHomomorphismByFunction(C,B,x->x);
#D:=[A,B,[CA,CB]];

#####################################################################
#####################################################################
InstallGlobalFunction(GraphOfGroupsTest,
function(D)
local
	Boole, x, VertexNames, EdgeNames, RangeNames;

VertexNames:=[];
EdgeNames:=[];
RangeNames:=[];
for x in D do
Boole:=false;
if IsGroup(x) and HasName(x) then 
Boole:=true; 
Append(VertexNames,[Name(x)]);fi;
if IsList(x) then
        if Length(x)=2 then 
        	#if IsGroupHomomorphism(x[1])
		#and IsGroupHomomorphism(x[2]) then
                if HasSource(x[1])
                and HasSource(x[2]) then

			if HasName(Range(x[1])) 
	       		and HasName(Source(x[1]))
			and HasName(Source(x[2]))
        		and HasName(Range(x[2])) then
			  if Name(Source(x[1]))=Name(Source(x[2]))
			  then Boole:=true;
			  Append(EdgeNames,[Name(Source(x[1]))]); 
			  Append(RangeNames,[Name(Range(x[1]))]);
			  Append(RangeNames,[Name(Range(x[2]))]);
			  fi;
			fi;
		fi;
	fi;
fi;

if not Boole then return false; fi;
od;

RangeNames:=SSortedList(RangeNames);

if Length(SSortedList(VertexNames))=Length(VertexNames)
and Length(RangeNames)=Length(Intersection(VertexNames,RangeNames))
and  Length(SSortedList(EdgeNames))=Length(EdgeNames) then
return true;
else return false;
fi;

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


#####################################################################
#####################################################################
InstallGlobalFunction(GraphOfGroupsDisplay,
function(arg)
local

	PositionName, tmpDir, tmpInlog, tmpIn2log, basicgif,
	D, Boole, Vertices, Edges,x,AppendTo,PrintTo;

AppendTo:=HAP_AppendTo;
PrintTo:=HAP_PrintTo;

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

#####################################################################
PositionName:=function(L,x)
return PositionProperty(L,n->Name(n)=Name(x));
end;
#####################################################################

D:=arg[1];
Vertices:=[];
Edges:=[];

if not GraphOfGroupsTest(D) then
Print("The list D does not represent a Graph of Groups \n");
return fail; fi;

for x in D do
if IsGroup(x) then Append(Vertices,[x]); fi;
if IsList(x) then Append(Edges,[x]); fi;
od;

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

AppendTo(tmpInlog," graph G { \n size=\"10,10\" \n node [shape=circle, style=filled,  color=gray] \n edge [style=\"setlinewidth(2)\"] \n");


for x in Vertices do
AppendTo(tmpInlog,PositionName(Vertices,x), "[label=\" ", Name(x), "\",fontsize=8]\n");
od;

for x in Edges do
AppendTo(tmpInlog,
PositionName(Vertices,Range(x[1]))," -- ",
PositionName(Vertices,Range(x[2])), "[label=\" ",Name(Source(x[1])),"\",fontsize=8,color=black] \n");
od;

AppendTo(tmpInlog,"} \n");
################ WRITTEN ############################################

Exec(Concatenation(NEATO_PATH,"-Tgif ",tmpInlog ," > ",basicgif));

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

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

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