-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgraph.cpp
More file actions
1976 lines (1601 loc) · 37.6 KB
/
graph.cpp
File metadata and controls
1976 lines (1601 loc) · 37.6 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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This is graph.cpp
Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux
See file main.cpp for full copyright notice
*/
#include "graph.h"
#include "directories.h"
#include "interactive.h"
namespace {
using namespace graph;
CoxSize dihedralOrder(CoxGraph& G, LFlags I);
ParSize extrQuotOrder(CoxGraph& G, LFlags I, Generator s);
void fillCoxAMatrix(CoxMatrix& m, Rank l);
void fillCoxBMatrix(CoxMatrix& m, Rank l);
void fillCoxDMatrix(CoxMatrix& m, Rank l);
void fillCoxEMatrix(CoxMatrix& m, Rank l);
void fillCoxFMatrix(CoxMatrix& m, Rank l);
void fillCoxGMatrix(CoxMatrix& m);
void fillCoxHMatrix(CoxMatrix& m, Rank l);
void fillCoxIMatrix(CoxMatrix& m);
void fillCoxaMatrix(CoxMatrix& m, Rank l);
void fillCoxbMatrix(CoxMatrix& m, Rank l);
void fillCoxcMatrix(CoxMatrix& m, Rank l);
void fillCoxdMatrix(CoxMatrix& m, Rank l);
void fillCoxeMatrix(CoxMatrix& m, Rank l);
void fillCoxfMatrix(CoxMatrix& m, Rank l);
void fillCoxgMatrix(CoxMatrix& m);
void fillCoxXMatrix(CoxMatrix& m, const Rank& l, const Type& t);
void fillCoxYMatrix(CoxMatrix& m, Rank l);
CoxSize finiteOrder(const Type& type, const Rank& rank);
Ulong gcd(Ulong a, Ulong b);
const Type& irrType(CoxGraph& G, LFlags I);
Generator lastGenerator(CoxGraph& G, LFlags I);
ParSize lastQuotOrder(const Type& type, Rank rank);
void makeCoxMatrix(CoxMatrix& m, const Type& x, const Rank& l);
void makeStar(List<LFlags>&star, const CoxMatrix& m, const Rank& l);
void makeStarOps(List<LFlags>&, const CoxMatrix& m, const Rank& l);
CoxEntry maxCoefficient(CoxGraph& G, LFlags I);
CoxEntry minCoefficient(CoxGraph& G, LFlags I);
CoxSize A_order(Rank rank);
CoxSize B_order(Rank rank);
CoxSize D_order(Rank rank);
};
/****************************************************************************
Chapter I -- The CoxGraph class.
The CoxGraph class provides access to the various data contained in the
Coxeter matrix : the matrix itself, and the underlying graph structure.
The following functions are provided :
- CoxGraph(x,l) : constructs a CoxGraph of type x and rank l;
- ~CoxGraph() : not implemented yet;
- component(I,s) : returns the connected component of s in I;
- extremities(I) : returns the extremities of I;
- nodes(I) : returns the nodes of I;
****************************************************************************/
namespace graph {
CoxGraph::CoxGraph(const Type& x, const Rank& l)
:d_type(x),d_rank(l),d_matrix(0),d_star(0)
/*
Initializes a Coxeter graph of type x and rank l.
*/
{
makeCoxMatrix(d_matrix,x,d_rank);
if (ERRNO)
return;
/* the restriction on the rank should be removed eventually */
if (l <= MEDRANK_MAX)
{
d_S = (LFlags)1 << d_rank-1;
d_S += d_S - 1;
makeStar(d_star,d_matrix,d_rank);
}
makeStarOps(d_starOps,d_matrix,l);
return;
}
CoxGraph::~CoxGraph()
/*
Automatic destruction is enough.
*/
{}
LFlags CoxGraph::component(LFlags I, Generator s) const
/*
Returns the bitmap of the connected component of s in I.
*/
{
LFlags nf = lmask[s];
LFlags f = 0;
while (nf) /* there are new elements to be considered */
{
f |= nf;
for (LFlags f1 = nf; f1; f1 &= f1-1)
nf |= (I & d_star[firstBit(f1)]);
nf &= ~f;
}
return f;
}
LFlags CoxGraph::extremities(LFlags I) const
/*
This function returns a bitmap of the set of points in I which are extremal
in the induced graph; this means that the valency of the point is one.
*/
{
LFlags f = 0;
LFlags f1 = I;
while (f1)
{
Generator s = firstBit(f1);
if (bitCount(d_star[s]&I) == 1) /* s is an extremity */
f |= lmask[s];
f1 &= f1-1;
}
return f;
}
LFlags CoxGraph::nodes(LFlags I) const
/*
This function returns a bitmap of the set of points in I which are nodes
for the induced graph; this means that the valency of the point is > 2.
*/
{
LFlags f,f1;
Generator s;
f = 0;
f1 = I;
while (f1)
{
s = firstBit(f1);
if (bitCount(d_star[s]&I) > 2) /* s is a node */
f |= lmask[s];
f1 &= f1-1;
}
return f;
}
};
/****************************************************************************
Chapter II -- Coxeter matrix functions.
This section provides the functions which will fill in the Coxeter matrices
in the predefined types, and those reading a matrix from a file, or reading
it in interactively. These functions are private to graph.c.
The following functions are provided :
for filling the matrix of a finite Weyl group :
- fillCoxAMatrix(m,l) : type A;
- fillCoxBMatrix(m,l) : type B = C;
- fillCoxDMatrix(m,l) : type D;
- fillCoxEMatrix(m,l) : type E;
- fillCoxFMatrix(m,l) : type F;
- fillCoxGMatrix(m,l) : type G;
- fillCoxHMatrix(m,l) : type H;
- fillCoxIMatrix(m,l) : type I (the remaining dihedrals) (interactive);
for filling the matrix of an affine Weyl group :
- fillCoxaMatrix(m,l) : type a;
- fillCoxbMatrix(m,l) : type b;
- fillCoxcMatrix(m,l) : type c;
- fillCoxdMatrix(m,l) : type d;
- fillCoxeMatrix(m,l) : type e;
- fillCoxfMatrix(m,l) : type f;
- fillCoxgMatrix(m,l) : type g;
for reading a Coxeter matrix from a file :
- fillCoxXMatrix(m,l);
for reading in a Coxeter matrix interactively :
- fillCoxYMatrix(m,l);
The functions filling in the actual data in the CoxGraph structure are :
- makeCoxMatrix(m,x,l) : allocates and fills the Coxeter matrix;
- makeStar(star,m,l) : allocates and fills the star array;
- makeStarOps(ops,m,l) : allocates and fills the starOps array;
****************************************************************************/
namespace {
void fillCoxAMatrix(CoxMatrix& m, Rank l)
{
for (Rank j = 1; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
return;
}
void fillCoxBMatrix(CoxMatrix& m, Rank l)
{
m[1] = 4;
m[l] = 4;
for (Rank j = 2; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
return;
}
void fillCoxDMatrix(CoxMatrix& m, Rank l)
{
if (l == 2)
return;
m[2] = 3;
m[l + 2] = 3;
m[2*l] = 3;
m[2*l + 1] = 3;
for (Rank j = 3; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
return;
}
void fillCoxEMatrix(CoxMatrix& m, Rank l)
{
m[2] = 3;
m[2*l] = 3;
if (l == 3)
return;
m[l + 3] = 3;
m[2*l + 3] = 3;
m[3*l + 1] = 3;
m[3*l + 2] = 3;
for (Rank j = 4; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
return;
}
void fillCoxFMatrix(CoxMatrix& m, Rank l)
{
for (Rank j = 1; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[l + 2] = 4;
m[2*l + 1] = 4;
return;
}
void fillCoxGMatrix(CoxMatrix& m)
{
m[1] = 6;
m[2] = 6;
return;
}
void fillCoxHMatrix(CoxMatrix& m, Rank l)
{
m[1] = 5;
m[l] = 5;
for (Rank j = 2; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
return;
}
void fillCoxIMatrix(CoxMatrix& m)
{
CoxEntry m_12;
m_12 = interactive::getCoxEntry(1,2);
if (ERRNO)
return;
m[1] = m_12;
m[2] = m_12;
return;
}
void fillCoxaMatrix(CoxMatrix& m, Rank l)
{
if (l == 2)
{
m[1] = 0;
m[2] = 0;
return;
}
for (Rank j = 1; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[l-1] = 3;
m[(l-1)*l] = 3;
return;
}
void fillCoxbMatrix(CoxMatrix& m, Rank l)
{
if (l == 3) { // go over to type c3
fillCoxcMatrix(m,3);
return;
}
m[1] = 4;
m[l] = 4;
for (Rank j = 2; j < l-1; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[(l-3)*l + (l-1)] = 3;
m[(l-1)*l + (l-3)] = 3;
return;
}
void fillCoxcMatrix(CoxMatrix& m, Rank l)
{
m[1] = 4;
m[l] = 4;
for (Rank j = 2; j < l-1; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[(l-2)*l + (l-1)] = 4;
m[(l-1)*l + (l-2)] = 4;
return;
}
void fillCoxdMatrix(CoxMatrix& m, Rank l)
{
m[2] = 3;
m[2*l] = 3;
for (Rank j = 2; j < l-1; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[(l-3)*l + (l-1)] = 3;
m[(l-1)*l + (l-3)] = 3;
return;
}
void fillCoxeMatrix(CoxMatrix& m, Rank l)
{
m[2] = 3;
m[2*l] = 3;
m[l + 3] = 3;
m[2*l + 3] = 3;
m[3*l + 1] = 3;
m[3*l + 2] = 3;
for (Rank j = 4; j < l-1; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
switch (l)
{
case 5:
m[l-1] = 3;
m[l + (l-1)] = 3;
m[(l-1)*l] = 3;
m[(l-1)*l + 1] = 3;
break;
case 6:
m[2*l + (l-1)] = 3;
m[(l-1)*l + 2] = 3;
break;
case 7:
m[l + (l-1)] = 3;
m[(l-1)*l + 1] = 3;
break;
case 8:
m[l-1] = 3;
m[(l-1)*l] = 3;
break;
case 9:
m[(l-2)*l + (l-1)] = 3;
m[(l-1)*l + (l-2)] = 3;
break;
}
return;
}
void fillCoxfMatrix(CoxMatrix& m, Rank l)
{
for (Rank j = 1; j < l; j++)
{
m[(j-1)*l + j] = 3;
m[j*l + (j-1)] = 3;
}
m[l + 2] = 4;
m[2*l + 1] = 4;
return;
}
void fillCoxgMatrix(CoxMatrix& m)
{
m[1] = 6;
m[3] = 6;
m[5] = 3;
m[7] = 3;
return;
}
void fillCoxXMatrix(CoxMatrix& m, const Rank& l, const Type& t)
/*
Recall that in type X the type is really a string, where the name
of a valid input file follows X, lying under coxeter_matrices. The
program reads the first l entries of the first l lines in the file;
this allows us sometimes to define a whole family of groups with
a single file.
NOTE : this should perhaps be completed by a recognition test, in order
to renumber the generators if necessary (and then modify the matrix
accordingly). For the time being, we leave it as is.
*/
{
static String buf(0);
using directories::COXMATRIX_DIR;
const String& name = t.name();
buf.setLength(strlen(COXMATRIX_DIR)+1+name.length()); // one char for `\`
sprintf(buf.ptr(),"%s/%s",COXMATRIX_DIR,name.ptr()+1);
FILE *inputfile = fopen(buf.ptr(),"r");
for (Rank i = 0; i < l; i++) {
for (Rank j = 0; j < l; j++) {
/* check for EOL */
if (interactive::endOfLine(inputfile)) {
Error(BAD_LINE,name.ptr()+1,l,i,j);
ERRNO = ABORT;
return;
}
m[i*l + j] = interactive::readCoxEntry(i,j,inputfile);
if (ERRNO) {
Error(ERRNO,i,j);
ERRNO = ABORT;
return;
}
/* check for symmetry */
if (j < i)
if (m[i*l + j] != m[j*l + i]) {
Error(NOT_SYMMETRIC,name.ptr()+1,&m,l,i,j);
ERRNO = ABORT;
return;
}
}
/* flush remaining line of the inputfile */
char c;
while((c = getc(inputfile)) != EOF)
if (c == '\n')
break;
}
fclose(inputfile);
return;
}
void fillCoxYMatrix(CoxMatrix& m, Rank l)
/*
This is the type for arbitrary input, where the coxeter matrix is gotten
interactively from the user. He is prompted only for entries i,j for
which i < j.
NOTE : this should be completed by a recognition test, in order
to renumber the generators if necessary (and then modify the matrix
accordingly). For the time being, we leave it as is.
*/
{
for (Rank i = 0; i < l; i++)
for (Rank j = i+1; j < l; j++) {
m[i*l + j] = interactive::getCoxEntry(i+1,j+1);
if (ERRNO) {
Error(ERRNO);
ERRNO = ERROR_WARNING;
return;
}
m[j*l + i] = m[i*l + j];
}
return;
}
void makeCoxMatrix(CoxMatrix& m, const Type& x, const Rank& l)
/*
Allocates and fills in the Coxeter matrix. In the case of type X,
this includes checking the input file for correct values; in the
case of type I, we need to get to get the only non-trivial entry
of the matrix from the user.
In the case of failure, it sets an error, and returns.
*/
{
m.setSize(l*l);
for (Ulong j = 0; j < static_cast<Ulong>(l*l); ++j)
m[j] = 2;
for (Ulong j = 0; j < l; ++j)
m[j*l+j] = 1;
switch (x[0])
{
case 'A':
fillCoxAMatrix(m,l);
break;
case 'B':
fillCoxBMatrix(m,l);
break;
case 'D':
fillCoxDMatrix(m,l);
break;
case 'E':
fillCoxEMatrix(m,l);
break;
case 'F':
fillCoxFMatrix(m,l);
break;
case 'G':
fillCoxGMatrix(m);
break;
case 'H':
fillCoxHMatrix(m,l);
break;
case 'I':
fillCoxIMatrix(m);
if (ERRNO)
return;
break;
case 'a':
fillCoxaMatrix(m,l);
break;
case 'b':
fillCoxbMatrix(m,l);
break;
case 'c':
fillCoxcMatrix(m,l);
break;
case 'd':
fillCoxdMatrix(m,l);
break;
case 'e':
fillCoxeMatrix(m,l);
break;
case 'f':
fillCoxfMatrix(m,l);
break;
case 'g':
fillCoxgMatrix(m);
break;
case 'X':
fillCoxXMatrix(m,l,x);
break;
case 'Y':
fillCoxYMatrix(m,l);
break;
}
return;
}
void makeStar(List<LFlags>& star, const CoxMatrix& m, const Rank& l)
/*
Makes the star-array of the Coxeter graph. This is an array of l
LFlags, flagging the "stars" of each generator in the Coxeter diagram.
*/
{
star.setSize(l);
for(Generator s = 0; s < l; s++) {
star[s] = 0;
for (Generator t = 0; t < l; t++)
if ((m[s*l + t] > 2) || (m[s*l + t] == 0))
star[s] |= lmask[t];
}
return;
}
void makeStarOps(List<LFlags>& ops, const CoxMatrix& m, const Rank& l)
/*
Makes the starOps array of the Coxeter graph. This array has an entry for
each finite edge in the graph, which holds the 2-element subset corresponding
to the edge.
*/
{
/* count number of finite edges */
Ulong count = 0;
for (Generator s = 0; s < l; ++s) {
for (Generator t = s+1; t < l; ++t) {
if ((m[s*l + t] > 2) && (m[s*l + t] != infty))
count++;
}
}
ops.setSize(count);
count = 0;
for (Generator s = 0; s < l; ++s) {
for (Generator t = s+1; t < l; ++t) {
if ((m[s*l + t] > 2) && (m[s*l + t] != infty)) {
ops[count] = lmask[s] | lmask[t];
count++;
}
}
}
return;
}
};
/****************************************************************************
Chapter III -- Graph analysis.
This section defines various functions for the analysis of subsets of the
Coxeter graph. The following functions are provided :
- isAffine(G,I);
- isConnected(G,I);
- isCrystallographic(G,I);
- isFinite(G,I);
- isLoop(G,I);
- isSimplyLaced(G,I);
- isTree(G,I);
In fact, the real work for isFinite and isAffine is provided in :
- irrType(G,I) : returns the type of an irreducible subset;
****************************************************************************/
namespace graph {
bool isAffine(CoxGraph& G, LFlags I)
/*
Returns true if the group generated by I is affine, false otherwise. Uses the
classification of the graphs of affine Coxeter groups.
It is assumed that I is already irreducible.
*/
{
const Type& type = irrType(G,I);
if (strchr("abcdefg",type[0])) /* group is affine */
return true;
else
return false;
}
bool isConnected(CoxGraph& G, LFlags I)
/*
Returns true if the graph induced on I is connected, false otherwise.
*/
{
if (I == 0)
return false;
Generator s = firstBit(I);
if (G.component(I,s) == I)
return true;
else
return false;
}
bool isCrystallographic(CoxGraph& G, LFlags I)
/*
Checks if the restriction of the Coxeter graph to I is crystallographic,
i.e., if the entries in the Coxeter matrix are all 2,3,4,6 or infinity.
*/
{
for (Generator s = 0; s < G.rank(); s++)
for (Generator t = s+1; t < G.rank(); t++)
{
switch (G.M(s,t)) {
case 0:
case 2:
case 3:
case 4:
case 6:
continue;
default:
return false;
};
}
return true;
}
bool isFinite(CoxGraph& G, LFlags I)
/*
Returns true if the group generated by I is finite, false otherwise. Uses the
classification of the graphs of finite Coxeter groups.
*/
{
while (I)
{
Generator s = firstBit(I);
LFlags f = G.component(I,s);
const Type& type = irrType(G,f);
if (strchr("ABCDEFGHI",type[0]) == NULL)
return false;
I &= ~f;
}
return true;
}
bool isLoop(CoxGraph& G, LFlags I)
/*
Returns 1 if the graph induced on I is a loop, 0 otherwise. Uses the
characterization that a loop is a connected graph for which all
valencies are equal to 2.
*/
{
if (!isConnected(G,I))
return false;
for (LFlags f = I; f; f &= f-1)
{
Generator s = firstBit(f);
if (bitCount(G.star(I,s)) != 2)
return false;
}
return true;
}
bool isSimplyLaced(CoxGraph& G, LFlags I)
/*
Returns true if the Coxeter graph restricted to I is simply laced (i.e., all
edges have label 3), false otherwise.
*/
{
for (LFlags fs = I; fs; fs &= fs-1)
{
Generator s = firstBit(fs);
for (LFlags ft = fs & fs-1; ft; ft &= ft-1)
{
Generator t = firstBit(ft);
if ((G.M(s,t) == 0) || (G.M(s,t) > 3))
return false;
}
}
return true;
}
bool isTree(CoxGraph& G, LFlags I)
/*
Returns 1 if the graph induced on I is a tree, 0 otherwise. Uses the
characterization that a tree is a connected graph for which the
number of edges is the number of vertices minus one.
*/
{
if (!isConnected(G,I))
return false;
unsigned edgecount = 0;
for (LFlags f = I; f; f &= f-1)
{
Generator s = firstBit(f);
edgecount += bitCount(G.star(I,s));
}
edgecount /= 2; /* each edge was counted twice */
if (edgecount == (bitCount(I) - 1))
return true;
else
return false;
}
};
namespace {
const Type& irrType(CoxGraph& G, LFlags I)
/*
Returns the type of the subgraph induced on I, if this subgraph is
irreducible, finite or affine. Assumes that irreducibility has already
been checked. Returns type "X" if the type is not defined.
The result is returned as type, which is a safe place until the next call
to irrType.
*/
{
static Type type("X");
if (bitCount(I) == 1) {
type[0] = 'A';
return type;
}
if (bitCount(I) == 2)
{
Generator s = firstBit(I);
Generator t = firstBit(I & I-1);
CoxEntry m = G.M(s,t);
switch (m)
{
case 0:
type[0] = 'a';
return type;
case 3:
type[0] = 'A';
return type;
case 4:
type[0] = 'B';
return type;
case 5:
type[0] = 'H';
return type;
case 6:
type[0] = 'G';
return type;
default:
type[0] = 'I';
return type;
};
}
/* from here on the rank is at least three */
if (!isTree(G,I)) /* type must be a_n */
{
if (!isLoop(G,I)) /* unknown type */
return type;
if (!isSimplyLaced(G,I)) /* unknown type */
return type;
type[0] = 'a';
return type;
}
/* from here on the graph is a tree */
CoxEntry m = maxCoefficient(G,I);
switch (m) {
case 3: { /* simply laced : type is A, D, E, d, e if known */
LFlags fn = G.nodes(I);
switch (bitCount(fn))
{
case 0: /* type A */
type[0] = 'A';
return type;
case 1: { /* type is D, E, e, or d5, if known */