-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleMagmaCode9.mgm
274 lines (246 loc) · 5.15 KB
/
ExampleMagmaCode9.mgm
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// Want to find the "distinct" necklaces
// with n black/white beads.
// Two necklaces are the "same"
// if an element of D8 changes one to the other.
// Represent a necklace by the set of black beads.
n := 8;
Dn := DihedralGroup(n);
DistinctNecklaces := {};
k := 3;
Nk := Subsets({1..n}, k);
while not IsEmpty(Nk) do
t := Rep(Nk);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nk,o);
end for;
end while;
DistinctNecklaces;
function Necklaces(n,k)
// Return necklaces with n total beads, k black
Dn := DihedralGroup(n);
DistinctNecklaces := {};
Nk := Subsets({1..n}, k);
while not IsEmpty(Nk) do
t := Rep(Nk);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nk,o);
end for;
end while;
return DistinctNecklaces;
end function;
function Necklaces(n)
// Return all necklaces with n total
// black/white beads
Dn := DihedralGroup(n);
DistinctNecklaces := {};
S := {1..n};
for k in [0..n] do
Nk := Subsets(S, k);
while not IsEmpty(Nk) do
t := Rep(Nk);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nk,o);
end for;
end while;
end for;
return DistinctNecklaces;
end function;
// For 3 colors: (copied from Necklaces(n,k))
function Necklaces(n, k, r)
// return necklaces with n beads of 3 colors
// k color '1', r of color '2', n-(k+r) color '0'
// n := 8; k := 2; r := 1;
Dn := DihedralGroup(n);
DistinctNecklaces := {};
//Need to define the set Nkr
S := {1..n};
Nkr := {};
Sk := Subsets(S,k);
for s in Sk do
Sr := Subsets(S diff s, r);
for t in Sr do
Include(~Nkr, [s,t]);
end for;
end for;
while not IsEmpty(Nkr) do
t := Rep(Nkr);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nkr,o);
end for;
end while;
return DistinctNecklaces;
end function;
// Possible ways to loop through values of k,r.
for k in [0..n] do
for r in [0..n-k] do
end for;
end for;
for k,r in [0..n] do
if k+r gt n then
continue;
end if;
end for;
G := Graph< 5 | {1,2}, {2,3}, {3,4}, {4,5}, {5,1} >;
G;
Vertices(G);
Edges(G);
V := VertexSet(G);
V;
1;
V!1;
1 eq V!1;
Type(1);
Type(V!1);
Sub3 := Subsets({1,2,3,4,5}, 3);
r := Random(Sub3);
r;
AssignVertexLabels(~G, [1,1,1,0,0]);
G;
Label(V!1);
IsVertexLabelled(V!1);
IsLabelled(V!1);
V := VertexSet(G);
IsLabelled(V!1);
Label(VertexSet(G)!1);
G := Graph< 5 | {1,2}, {2,3}, {3,4}, {4,5}, {5,1} >;
V := VertexSet(G);
AssignVertexLabels(~G, [1,1,1,0,0]);
V := VertexSet(G);
n := 10;
k := 4;
r := 2;
S1 := Subsets({1..10}, k);
s1 := Random(S1);
s1;
S2 := Subsets( {1..10} - s1 , r);
S2 := Subsets( {1..10} diff s1 , r);
{1..10} diff s1;
s2 := Random(S2);
s1;
s2;
A := AutomorphismGroup(G);
G := Graph< 5 | {1,2}, {2,3}, {3,4}, {4,5}, {5,1} >;
1;2Ak := 4;
V := VertexSet(G);
A := AutomorphismGroup(G);
s := [{V!1, V!2}, {V!3}];
Orbit(A,s);
Orbit(A, V!1);
A;
s := [{1, 2}, {3}];
Orbit(A,s);
Nkr := {};
Sk := Subsets({1..8}, 3);
for sk in Sk do
Sr := Subsets({1..8} diff sk, 2);
for sr in Sr do
Include(~Nkr, [sk,sr]);
end for;
end for;
#Nkr;
Nkr;
{ N : N in Nkr | N[1] eq {1,2,3} };
t := Random(Nkr);
t;
D8 := DihedralGroup(8);
Orbit(D8, t);
DistinctNecklaces := {};
#Nkr;
while not IsEmpty(Nkr) do
t := Rep(Nkr);
Include(~DistinctNecklaces, t);
O := Orbit(D8,t);
for o in O do
Exclude(~Nkr,o);
end for;
end while;
Nkr;
DistinctNecklaces;
#DistinctNecklaces;
Subsets(3,2);
function Necklaces(n,k)
// Return necklaces with n total beads, k black
Dn := DihedralGroup(n);
DistinctNecklaces := {};
Nk := Subsets({1..n}, k);
while not IsEmpty(Nk) do
t := Rep(Nk);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nk,o);
end for;
end while;
return DistinctNecklaces;
end function;
Necklaces(8,3);
n := 8; k := 2; r := 1;
Dn := DihedralGroup(n);
DistinctNecklaces := {};
//Need to define the set Nkr
S := {1..n};
Nkr := {};
Sk := Subsets(S,k)
for s in Sk do
Sr := Subsets(S diff s, r);
for t in Sr do
Include(~Nkr, [s,t]);
end for;
end for;
n := 8; k := 2; r := 1;
Dn := DihedralGroup(n);
DistinctNecklaces := {};
S := {1..n};
Nkr := {};
Sk := Subsets(S,k);
for s in Sk do
Sr := Subsets(S diff s, r);
for t in Sr do
Include(~Nkr, [s,t]);
end for;
end for;
Nkr;
while not IsEmpty(Nkr) do
t := Rep(Nkr);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nkr,o);
end for;
end while;
DistinctNecklaces;
function Necklaces(n, k, r)
// return necklaces with n beads of 3 colors
// k color '1', r of color '2', n-(k+r) color '0'
// n := 8; k := 2; r := 1;
Dn := DihedralGroup(n);
DistinctNecklaces := {};
//Need to define the set Nkr
S := {1..n};
Nkr := {};
Sk := Subsets(S,k);
for s in Sk do
Sr := Subsets(S diff s, r);
for t in Sr do
Include(~Nkr, [s,t]);
end for;
end for;
while not IsEmpty(Nkr) do
t := Rep(Nkr);
Include(~DistinctNecklaces, t);
O := Orbit(Dn,t);
for o in O do
Exclude(~Nkr,o);
end for;
end while;
return DistinctNecklaces;
end function;
Necklaces(6, 2,2);