-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathoper.xml
2491 lines (2278 loc) · 92.9 KB
/
oper.xml
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
#############################################################################
##
#W oper.xml
#Y Copyright (C) 2014-19 James D. Mitchell
##
## Licensing information can be found in the README file of this package.
##
#############################################################################
##
<#GAPDoc Label="IsSubdigraph">
<ManSection>
<Oper Name="IsSubdigraph" Arg="super, sub"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
If <A>super</A> and <A>sub</A> are digraphs, then this operation returns
<K>true</K> if <A>sub</A> is a subdigraph of <A>super</A>, and <K>false</K>
if it is not. <P/>
A digraph <A>sub</A> is a <E>subdigraph</E> of a digraph <A>super</A> if
<A>sub</A> and <A>super</A> share the same number of vertices, and the
collection of edges of <A>super</A> (including repeats) contains the
collection of edges of <A>sub</A> (including repeats). <P/>
In other words, <A>sub</A> is a subdigraph of <A>super</A> if and only if
<C>DigraphNrVertices(<A>sub</A>) = DigraphNrVertices(<A>super</A>)</C>, and
for each pair of vertices <C>i</C> and <C>j</C>, there are at least as many
edges of the form <C>[i, j]</C> in <A>super</A> as there are in <A>sub</A>.
<P/>
<Example><![CDATA[
gap> g := Digraph([[2, 3], [1], [2, 3]]);
<immutable digraph with 3 vertices, 5 edges>
gap> h := Digraph([[2, 3], [], [2]]);
<immutable digraph with 3 vertices, 3 edges>
gap> IsSubdigraph(g, h);
true
gap> IsSubdigraph(h, g);
false
gap> IsSubdigraph(CompleteDigraph(4), CycleDigraph(4));
true
gap> IsSubdigraph(CycleDigraph(4), ChainDigraph(4));
true
gap> g := Digraph([[2, 2], [1]]);
<immutable multidigraph with 2 vertices, 3 edges>
gap> h := Digraph([[2], [1]]);
<immutable digraph with 2 vertices, 2 edges>
gap> IsSubdigraph(g, h);
true
gap> IsSubdigraph(h, g);
false]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="IsUndirectedSpanningTree">
<ManSection>
<Oper Name="IsUndirectedSpanningTree" Arg="super, sub"/>
<Oper Name="IsUndirectedSpanningForest" Arg="super, sub"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
The operation <C>IsUndirectedSpanningTree</C> returns <K>true</K> if the
digraph <A>sub</A> is an undirected spanning tree of the digraph
<A>super</A>, and the operation <C>IsUndirectedSpanningForest</C> returns
<K>true</K> if the digraph <A>sub</A> is an undirected spanning forest of
the digraph <A>super</A>. <P/>
An <E>undirected spanning tree</E> of a digraph <A>super</A> is a subdigraph
of <A>super</A> that is an undirected tree (see <Ref Oper="IsSubdigraph" />
and <Ref Prop="IsUndirectedTree" />). Note that a digraph whose <Ref
Oper="MaximalSymmetricSubdigraph"/> is not connected has no undirected
spanning trees (see <Ref Prop="IsConnectedDigraph"/>). <P/>
An <E>undirected spanning forest</E> of a digraph <A>super</A> is a
subdigraph of <A>super</A> that is an undirected forest (see <Ref
Oper="IsSubdigraph"/> and <Ref Prop="IsUndirectedForest"/>), and is not
contained in any larger such subdigraph of <A>super</A>. Equivalently, an
undirected spanning forest is a subdigraph of <A>super</A> whose connected
components coincide with those of the <Ref
Oper="MaximalSymmetricSubdigraph"/> of <A>super</A> (see <Ref
Attr="DigraphConnectedComponents"/>). <P/>
Note that an undirected spanning tree is an undirected spanning forest that
is connected.
<Example><![CDATA[
gap> D := CompleteDigraph(4);
<immutable complete digraph with 4 vertices>
gap> tree := Digraph([[3], [4], [1, 4], [2, 3]]);
<immutable digraph with 4 vertices, 6 edges>
gap> IsSubdigraph(D, tree) and IsUndirectedTree(tree);
true
gap> IsUndirectedSpanningTree(D, tree);
true
gap> forest := EmptyDigraph(4);
<immutable empty digraph with 4 vertices>
gap> IsSubdigraph(D, forest) and IsUndirectedForest(forest);
true
gap> IsUndirectedSpanningForest(D, forest);
false
gap> IsSubdigraph(tree, forest);
true
gap> D := DigraphDisjointUnion(CycleDigraph(2), CycleDigraph(2));
<immutable digraph with 4 vertices, 4 edges>
gap> IsUndirectedTree(D);
false
gap> IsUndirectedForest(D) and IsUndirectedSpanningForest(D, D);
true]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphReverseEdges">
<ManSection>
<Oper Name="DigraphReverseEdges" Arg="digraph, edges"
Label="for a digraph and a list of edges"/>
<Oper Name="DigraphReverseEdge" Arg="digraph, edge"
Label="for a digraph and an edge"/>
<Oper Name="DigraphReverseEdge" Arg="digraph, src, ran"
Label="for a digraph, source, and range"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph without multiple edges, and <A>edges</A> is a
list of pairs of vertices of <A>digraph</A> (the entries of each pair
corresponding to the source and the range of an edge, respectively),
then <C>DigraphReverseEdges</C> returns a digraph constructed from
<A>digraph</A> by reversing the orientation of every edge specified by
<A>edges</A>. If only one edge is to be reversed, then
<C>DigraphReverseEdge</C> can be used instead. In this case, the second
argument should just be a single vertex-pair, or the second and third
arguments should be the source and range of an edge respectively. <P/>
Note that even though <A>digraph</A> cannot have multiple edges, the
output may have multiple edges. <P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the edges
are reversed in <A>digraph</A>. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, an immutable copy of <A>digraph</A> with the
specified edges reversed is returned.<P/>
<Example><![CDATA[
gap> D := DigraphFromDiSparse6String(".Tg?i@s?t_e?_qEsC");
<immutable digraph with 21 vertices, 8 edges>
gap> DigraphEdges(D);
[ [ 1, 2 ], [ 1, 7 ], [ 1, 8 ], [ 5, 21 ], [ 7, 19 ], [ 9, 1 ],
[ 11, 2 ], [ 21, 1 ] ]
gap> new := DigraphReverseEdge(D, [7, 19]);
<immutable digraph with 21 vertices, 8 edges>
gap> DigraphEdges(new);
[ [ 1, 2 ], [ 1, 7 ], [ 1, 8 ], [ 5, 21 ], [ 9, 1 ], [ 11, 2 ],
[ 19, 7 ], [ 21, 1 ] ]
gap> D2 := DigraphMutableCopy(new);;
gap> new := DigraphReverseEdges(D2, [[19, 7]]);;
gap> D2 = new;
true
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="OnDigraphs">
<ManSection>
<Oper Name="OnDigraphs" Arg="digraph, perm"
Label="for a digraph and a perm"/>
<Oper Name="OnDigraphs" Arg="digraph, trans"
Label="for a digraph and a transformation"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph, and the second argument <A>perm</A> is a
<E>permutation</E> of the vertices of <A>digraph</A>, then this operation
returns a digraph constructed by relabelling the vertices of
<A>digraph</A> according to <A>perm</A>. Note that for an automorphism
<C>f</C> of a digraph, we have <C>OnDigraphs(<A>digraph</A>, f) =
</C><A>digraph</A>.
<P/>
If the second argument is a <E>transformation</E> <A>trans</A> of the
vertices of <A>digraph</A>, then this operation returns a digraph
constructed by transforming the source and range of each edge according to
<A>trans</A>. Thus a vertex which does not appear in the image of
<A>trans</A> will be isolated in the returned digraph, and the returned
digraph may contain multiple edges, even if <A>digraph</A> does not.
If <A>trans</A> is mathematically a permutation, then the result coincides
with <C>OnDigraphs(<A>digraph</A>, AsPermutation(<A>trans</A>))</C>.
<P/>
The <Ref Oper="DigraphVertexLabels"/> of <A>digraph</A> will not be retained
in the returned digraph. <P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then
relabelling of the vertices is performed directly on <A>digraph</A>.
If <A>digraph</A> belongs to <Ref Filt="IsImmutableDigraph"/>, an immutable
copy of <A>digraph</A> with the vertices relabelled is returned.<P/>
<Example><![CDATA[
gap> D := Digraph([[3], [1, 3, 5], [1], [1, 2, 4], [2, 3, 5]]);
<immutable digraph with 5 vertices, 11 edges>
gap> new := OnDigraphs(D, (1, 2));
<immutable digraph with 5 vertices, 11 edges>
gap> OutNeighbours(new);
[ [ 2, 3, 5 ], [ 3 ], [ 2 ], [ 2, 1, 4 ], [ 1, 3, 5 ] ]
gap> D := Digraph([[2], [], [2]]);
<immutable digraph with 3 vertices, 2 edges>
gap> t := Transformation([1, 2, 1]);;
gap> new := OnDigraphs(D, t);
<immutable multidigraph with 3 vertices, 2 edges>
gap> OutNeighbours(new);
[ [ 2, 2 ], [ ], [ ] ]
gap> ForAll(DigraphEdges(D),
> e -> IsDigraphEdge(new, [e[1] ^ t, e[2] ^ t]));
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="OnMultiDigraphs">
<ManSection>
<Oper Name="OnMultiDigraphs" Arg="digraph, pair"/>
<Oper Name="OnMultiDigraphs" Arg="digraph, perm1, perm2"
Label="for a digraph, perm, and perm"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph, and <A>pair</A> is a pair consisting of a
permutation of the vertices and a permutation of the edges of
<A>digraph</A>, then this operation returns a digraph
constructed by relabelling the vertices and edges of <A>digraph</A>
according to <A>perm[1]</A> and <A>perm[2]</A>, respectively. <P/>
In its second form, <C>OnMultiDigraphs</C> returns a digraph with vertices
and edges permuted by <A>perm1</A> and <A>perm2</A>, respectively. <P/>
Note that <C>OnDigraphs(<A>digraph</A>,
perm)=OnMultiDigraphs(<A>digraph</A>, [perm, ()])</C> where <C>perm</C> is
a permutation of the vertices of <A>digraph</A>. If you are only interested
in the action of a permutation on the vertices of a digraph, then you can
use <C>OnDigraphs</C> instead of <C>OnMultiDigraphs</C>.
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then
relabelling of the vertices is performed directly on <A>digraph</A>.
If <A>digraph</A> belongs to <Ref Filt="IsImmutableDigraph"/>, an immutable
copy of <A>digraph</A> with the vertices relabelled is returned.<P/>
<Example><![CDATA[
gap> D1 := Digraph([
> [3, 6, 3], [], [3], [9, 10], [9], [], [], [10, 4, 10], [], []]);
<immutable multidigraph with 10 vertices, 10 edges>
gap> p := BlissCanonicalLabelling(D1);
[ (1,7)(3,6)(4,10)(5,9), () ]
gap> D2 := OnMultiDigraphs(D1, p);
<immutable multidigraph with 10 vertices, 10 edges>
gap> OutNeighbours(D2);
[ [ ], [ ], [ ], [ ], [ ], [ 6 ], [ 6, 3, 6 ], [ 4, 10, 4 ],
[ 5 ], [ 5, 4 ] ]]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="OnTuplesDigraphs">
<ManSection>
<Oper Name="OnTuplesDigraphs" Arg="list, perm"
Label="for a list of digraphs and a perm"/>
<Oper Name="OnSetsDigraphs" Arg="list, perm"
Label="for a set of digraphs and a perm"/>
<Returns>A list or set of digraphs.</Returns>
<Description>
If <A>list</A> is a list of digraphs, and <A>perm</A> is a
<E>permutation</E> of the vertices of the digraphs in <A>list</A>, then
<Ref Oper="OnTuplesDigraphs" Label="for a list of digraphs and a perm"/>
returns a new list constructed by applying <A>perm</A> via
<Ref Oper="OnDigraphs" Label="for a digraph and a perm"/>
to a copy (with the same mutability) of each entry of <A>list</A> in turn.
<P/>
More precisely, <C>OnTuplesDigraphs(<A>list</A>,<A>perm</A>)</C> is a list
of length <C>Length(<A>list</A>)</C>, whose <C>i</C>-th entry is
<C>OnDigraphs(DigraphCopy(<A>list</A>[i]), <A>perm</A>)</C>.
<P/>
If <A>list</A> is moreover a &GAP; set (i.e. a duplicate-free sorted list),
then <Ref Oper="OnSetsDigraphs" Label="for a set of digraphs and a perm"/>
returns the sorted output of
<Ref Oper="OnTuplesDigraphs" Label="for a list of digraphs and a perm"/>,
which is therefore again a set.
<Example><![CDATA[
gap> list := [CycleDigraph(IsMutableDigraph, 6),
> DigraphReverse(CycleDigraph(6))];
[ <mutable digraph with 6 vertices, 6 edges>,
<immutable digraph with 6 vertices, 6 edges> ]
gap> p := (1, 6)(2, 5)(3, 4);;
gap> result_tuples := OnTuplesDigraphs(list, p);
[ <mutable digraph with 6 vertices, 6 edges>,
<immutable digraph with 6 vertices, 6 edges> ]
gap> result_tuples[2] = OnDigraphs(list[2], p);
true
gap> result_tuples = list;
false
gap> result_tuples = Reversed(list);
true
gap> result_sets := OnSetsDigraphs(list, p);
[ <immutable digraph with 6 vertices, 6 edges>,
<mutable digraph with 6 vertices, 6 edges> ]
gap> result_sets = list;
true]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphAddVertex">
<ManSection>
<Oper Name="DigraphAddVertex" Arg="digraph[, label ]"/>
<Returns>A digraph.</Returns>
<Description>
The operation returns a digraph constructed from <A>digraph</A> by adding a
single new vertex, and no new edges. <P/>
If the optional second argument <A>label</A> is a &GAP; object,
then the new vertex will be labelled <A>label</A>.
<P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the
vertex is added directly to <A>digraph</A>. If <A>digraph</A> belongs to
<Ref Filt="IsImmutableDigraph"/>, an immutable copy of <A>digraph</A> with
the additional vertex is returned.<P/>
<Example><![CDATA[
gap> D := CompleteDigraph(3);
<immutable complete digraph with 3 vertices>
gap> new := DigraphAddVertex(D);
<immutable digraph with 4 vertices, 6 edges>
gap> D = new;
false
gap> DigraphVertices(new);
[ 1 .. 4 ]
gap> new := DigraphAddVertex(D, Group([(1, 2)]));
<immutable digraph with 4 vertices, 6 edges>
gap> DigraphVertexLabels(new);
[ 1, 2, 3, Group([ (1,2) ]) ]
gap> D := CompleteBipartiteDigraph(IsMutableDigraph, 2, 3);
<mutable digraph with 5 vertices, 12 edges>
gap> new := DigraphAddVertex(D);
<mutable digraph with 6 vertices, 12 edges>
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphAddVertices">
<ManSection>
<Oper Name="DigraphAddVertices" Arg="digraph, m"
Label="for a digraph and an integer"/>
<Oper Name="DigraphAddVertices" Arg="digraph, labels"
Label="for a digraph and a list of labels"/>
<!-- The 3-argument version is deliberately undocumented. It is redundant,
but it is included for backwards compatibility. -->
<Returns>A digraph.</Returns>
<Description>
For a non-negative integer <A>m</A>, this operation returns a digraph
constructed from <A>digraph</A> by adding <A>m</A> new vertices.
<P/>
Otherwise, if <A>labels</A> is a list
consisting of <C>k</C> &GAP; objects, then this operation returns a
digraph constructed from <A>digraph</A> by adding <C>k</C> new vertices,
which are labelled according to this list.
<P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the
vertices are added directly to <A>digraph</A>, which is changed in-place.
If <A>digraph</A> belongs to <Ref Filt="IsImmutableDigraph"/>, then
<A>digraph</A> itself is returned if no vertices are added
(i.e. <C><A>m</A>=0</C> or <A>labels</A> is empty), otherwise
the result is a new immutable digraph.
<P/>
<Example><![CDATA[
gap> D := CompleteDigraph(3);
<immutable complete digraph with 3 vertices>
gap> new := DigraphAddVertices(D, 3);
<immutable digraph with 6 vertices, 6 edges>
gap> DigraphVertices(new);
[ 1 .. 6 ]
gap> new := DigraphAddVertices(D, [Group([(1, 2)]), "d"]);
<immutable digraph with 5 vertices, 6 edges>
gap> DigraphVertexLabels(new);
[ 1, 2, 3, Group([ (1,2) ]), "d" ]
gap> DigraphAddVertices(D, 0) = D;
true
gap> D := CompleteBipartiteDigraph(IsMutableDigraph, 2, 3);
<mutable digraph with 5 vertices, 12 edges>
gap> new := DigraphAddVertices(D, 4);
<mutable digraph with 9 vertices, 12 edges>
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphRemoveVertex">
<ManSection>
<Oper Name="DigraphRemoveVertex" Arg="digraph, v"/>
<Returns>A digraph.</Returns>
<Description>
If <A>v</A> is a vertex of <A>digraph</A>, then this operation returns a
digraph constructed from <A>digraph</A> by removing vertex <A>v</A>,
along with any edge whose source or range vertex is <A>v</A>.<P/>
If <A>digraph</A> has <C>n</C> vertices, then the vertices of the returned
digraph are <C>[1..n-1]</C>, but the original labels can be
accessed via <Ref Oper="DigraphVertexLabels"/>. <P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the
vertex is removed directly from <A>digraph</A>. If <A>digraph</A> belongs
to <Ref Filt="IsImmutableDigraph"/>, an immutable copy of <A>digraph</A>
without the vertex is returned.<P/>
<Example><![CDATA[
gap> D := Digraph(["a", "b", "c"],
> ["a", "a", "b", "c", "c"],
> ["b", "c", "a", "a", "c"]);
<immutable digraph with 3 vertices, 5 edges>
gap> DigraphVertexLabels(D);
[ "a", "b", "c" ]
gap> DigraphEdges(D);
[ [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 3, 1 ], [ 3, 3 ] ]
gap> new := DigraphRemoveVertex(D, 2);
<immutable digraph with 2 vertices, 3 edges>
gap> DigraphVertexLabels(new);
[ "a", "c" ]
gap> D := CycleDigraph(IsMutableDigraph, 5);
<mutable digraph with 5 vertices, 5 edges>
gap> new := DigraphRemoveVertex(D, 1);
<mutable digraph with 4 vertices, 3 edges>
gap> DigraphVertexLabels(D);
[ 2, 3, 4, 5 ]
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphRemoveVertices">
<ManSection>
<Oper Name="DigraphRemoveVertices" Arg="digraph, verts"/>
<Returns>A digraph.</Returns>
<Description>
If <A>verts</A> is a (possibly empty) duplicate-free list of vertices of
<A>digraph</A>, then this operation returns a digraph constructed from
<A>digraph</A> by removing every vertex in <A>verts</A>, along with any edge
whose source or range vertex is in <A>verts</A>.<P/>
If <A>digraph</A> has <C>n</C> vertices, then the vertices of the new
digraph are <C>[1 .. n-Length(<A>verts</A>)]</C>, but the
original labels can be accessed via <Ref Oper="DigraphVertexLabels"/>. <P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the
vertices are removed directly from <A>digraph</A>. If <A>digraph</A> belongs
to <Ref Filt="IsImmutableDigraph"/>, an immutable copy of <A>digraph</A>
without the vertices is returned.<P/>
<Example><![CDATA[
gap> D := Digraph([[3], [1, 3, 5], [1], [1, 2, 4], [2, 3, 5]]);
<immutable digraph with 5 vertices, 11 edges>
gap> SetDigraphVertexLabels(D, ["a", "b", "c", "d", "e"]);
gap> new := DigraphRemoveVertices(D, [2, 4]);
<immutable digraph with 3 vertices, 4 edges>
gap> DigraphVertexLabels(new);
[ "a", "c", "e" ]
gap> D := CycleDigraph(IsMutableDigraph, 5);
<mutable digraph with 5 vertices, 5 edges>
gap> new := DigraphRemoveVertices(D, [1, 3]);
<mutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(D);
[ 2, 4, 5 ]
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphAddEdge">
<ManSection>
<Oper Name="DigraphAddEdge" Arg="digraph, edge"
Label="for a digraph and an edge"/>
<Oper Name="DigraphAddEdge" Arg="digraph, src, ran"
Label="for a digraph, source, and range"/>
<Returns>A digraph.</Returns>
<Description>
If <A>edge</A> is a pair of vertices of <A>digraph</A>, or <A>src</A> and
<A>ran</A> are vertices of <A>digraph</A>,
then this operation returns a digraph constructed from <A>digraph</A>
by adding a new edge with source <A>edge</A><C>[1]</C> [<A>src</A>] and range
<A>edge</A><C>[2]</C> [<A>ran</A>].
<P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the edge
is added directly to <A>digraph</A>. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, then an immutable copy of <A>digraph</A> with the
additional edge is returned. <P/>
<Example><![CDATA[
gap> D1 := Digraph([[2], [3], []]);
<immutable digraph with 3 vertices, 2 edges>
gap> DigraphEdges(D1);
[ [ 1, 2 ], [ 2, 3 ] ]
gap> D2 := DigraphAddEdge(D1, [3, 1]);
<immutable digraph with 3 vertices, 3 edges>
gap> DigraphEdges(D2);
[ [ 1, 2 ], [ 2, 3 ], [ 3, 1 ] ]
gap> D3 := DigraphAddEdge(D2, [2, 3]);
<immutable multidigraph with 3 vertices, 4 edges>
gap> DigraphEdges(D3);
[ [ 1, 2 ], [ 2, 3 ], [ 2, 3 ], [ 3, 1 ] ]
gap> D := CycleDigraph(IsMutableDigraph, 4);
<mutable digraph with 4 vertices, 4 edges>
gap> new := DigraphAddEdge(D, [1, 3]);
<mutable digraph with 4 vertices, 5 edges>
gap> DigraphEdges(new);
[ [ 1, 2 ], [ 1, 3 ], [ 2, 3 ], [ 3, 4 ], [ 4, 1 ] ]
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphAddEdges">
<ManSection>
<Oper Name="DigraphAddEdges" Arg="digraph, edges"/>
<Returns>A digraph.</Returns>
<Description>
If <A>edges</A> is a (possibly empty) list of pairs of vertices of
<A>digraph</A>, then this operation returns a digraph constructed from
<A>digraph</A> by adding the edges specified by <A>edges</A>. More
precisely, for every <C>edge</C> in <A>edges</A>, a new edge
will be added with source <C>edge[1]</C> and range <C>edges[2]</C>.
<P/>
If an edge is included in <A>edges</A> with multiplicity <C>k</C>,
then it will be added <C>k</C> times.
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the edges
are added directly to <A>digraph</A>. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, then the result is returned as an immutable
digraph.
<P/>
<Example><![CDATA[
gap> func := function(n)
> local source, range, i;
> source := [];
> range := [];
> for i in [1 .. n - 2] do
> Add(source, i);
> Add(range, i + 1);
> od;
> return Digraph(n, source, range);
> end;;
gap> D := func(1024);
<immutable digraph with 1024 vertices, 1022 edges>
gap> new := DigraphAddEdges(D,
> [[1023, 1024], [1, 1024], [1023, 1024], [1024, 1]]);
<immutable multidigraph with 1024 vertices, 1026 edges>
gap> D = new;
false
gap> D2 := DigraphMutableCopy(func(1024));
<mutable digraph with 1024 vertices, 1022 edges>
gap> new := DigraphAddEdges(D2,
> [[1023, 1024], [1, 1024], [1023, 1024], [1024, 1]]);
<mutable multidigraph with 1024 vertices, 1026 edges>
gap> D2 = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphRemoveEdge">
<ManSection>
<Oper Name="DigraphRemoveEdge" Arg="digraph, edge"
Label="for a digraph and an edge"/>
<Oper Name="DigraphRemoveEdge" Arg="digraph, src, ran"
Label="for a digraph, source, and range"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph with no multiple edges and <A>edge</A> is a
pair of vertices of <A>digraph</A>, or <A>src</A> and <A>ran</A> are
vertices of <A>digraph</A>, then this operation returns a digraph
constructed from <A>digraph</A> by removing the edge specified by
<A>edge</A> or <A>[src, ran]</A>. <P/>
If <A>digraph</A> belongs to <Ref
Filt="IsMutableDigraph"/>, then the edge is removed directly from
<A>digraph</A>. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, an immutable copy of <A>digraph</A> without
the edge is returned.
<P/>
Note that if <A>digraph</A> belongs to <Ref Filt="IsImmutableDigraph"/>,
then a new copy of <A>digraph</A> will be returned even if <A>edge</A> or
<A>[src, ran]</A> does not define an edge of <A>digraph</A>.<P/>
<Example><![CDATA[
gap> D := CycleDigraph(250000);
<immutable cycle digraph with 250000 vertices>
gap> D := DigraphRemoveEdge(D, [250000, 1]);
<immutable digraph with 250000 vertices, 249999 edges>
gap> new := DigraphRemoveEdge(D, [25000, 2]);;
gap> new = D;
true
gap> IsIdenticalObj(new, D);
false
gap> D := DigraphMutableCopy(D);;
gap> new := DigraphRemoveEdge(D, 2500, 2);;
gap> IsIdenticalObj(new, D);
true]]>
</Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphRemoveEdges">
<ManSection>
<Oper Name="DigraphRemoveEdges" Arg="digraph, edges"/>
<Returns>A digraph.</Returns>
<Description>
If one of the following holds:
<List>
<Item>
<A>digraph</A> is a digraph with no multiple edges, and
<A>edges</A> is a list of pairs of vertices of <A>digraph</A>, or
</Item>
<Item> <A>digraph</A> is a digraph and <A>edges</A> is an empty list </Item>
</List>
then this operation returns a digraph constructed from <A>digraph</A>
by removing all of the edges specified by <A>edges</A>
(see <Ref Oper="DigraphRemoveEdge" Label="for a digraph and an edge"/>).
<P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then the edge
is removed directly from <A>digraph</A>. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, the edge is removed from an immutable copy of
<A>digraph</A> and this new digraph is returned.<P/>
Note that if <A>edges</A> is empty, then this operation
will always return <A>digraph</A> rather than a copy. Also, if any element
of <A>edges</A> is invalid (i.e. does not define an edge of <A>digraph</A>)
then that element will simply be ignored.
<Example><![CDATA[
gap> D := CycleDigraph(250000);
<immutable cycle digraph with 250000 vertices>
gap> D := DigraphRemoveEdges(D, [[250000, 1]]);
<immutable digraph with 250000 vertices, 249999 edges>
gap> D := DigraphMutableCopy(D);
<mutable digraph with 250000 vertices, 249999 edges>
gap> new := DigraphRemoveEdges(D, [[1, 2], [2, 3], [3, 100]]);
<mutable digraph with 250000 vertices, 249997 edges>
gap> new = D;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="InducedSubdigraph">
<ManSection>
<Oper Name="InducedSubdigraph" Arg="digraph, verts"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph, and <A>verts</A> is a subset of the
vertices of <A>digraph</A>, then this operation returns a digraph
constructed from <A>digraph</A> by retaining precisely those vertices in
<A>verts</A>, and those edges whose source and range vertices are both
contained in <A>verts</A>. <P/>
The vertices of the induced subdigraph are
<C>[1..Length(verts)]</C> but the original vertex labels can be
accessed via <Ref Oper="DigraphVertexLabels"/>. <P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then
<A>digraph</A> is modified in place. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, a new immutable digraph containing the
appropriate
vertices and edges is returned.<P/>
<Example><![CDATA[
gap> D := Digraph([[1, 1, 2, 3, 4, 4], [1, 3, 4], [3, 1], [1, 1]]);
<immutable multidigraph with 4 vertices, 13 edges>
gap> InducedSubdigraph(D, [1, 3, 4]);
<immutable multidigraph with 3 vertices, 9 edges>
gap> DigraphVertices(last);
[ 1 .. 3 ]
gap> D := DigraphMutableCopy(D);
<mutable multidigraph with 4 vertices, 13 edges>
gap> new := InducedSubdigraph(D, [1, 3, 4]);
<mutable multidigraph with 3 vertices, 9 edges>
gap> D = new;
true
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="OutDegreeOfVertex">
<ManSection>
<Oper Name="OutDegreeOfVertex" Arg="digraph, vertex"/>
<Returns>The non-negative integer.</Returns>
<Description>
This operation returns the out-degree of the vertex <A>vertex</A> in the
digraph <A>digraph</A>.
The out-degree of <A>vertex</A> is the number of edges in <A>digraph</A>
whose source is <A>vertex</A>.
<P/>
<Example><![CDATA[
gap> D := Digraph([
> [2, 2, 1], [1, 4], [2, 2, 4, 2], [1, 1, 2, 2, 1, 2, 2]]);
<immutable multidigraph with 4 vertices, 16 edges>
gap> OutDegreeOfVertex(D, 1);
3
gap> OutDegreeOfVertex(D, 2);
2
gap> OutDegreeOfVertex(D, 3);
4
gap> OutDegreeOfVertex(D, 4);
7
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="OutNeighboursOfVertex">
<ManSection>
<Oper Name="OutNeighboursOfVertex" Arg="digraph, vertex"/>
<Oper Name="OutNeighborsOfVertex" Arg="digraph, vertex"/>
<Returns>A list of vertices.</Returns>
<Description>
This operation returns the list <C>out</C> of vertices of the digraph
<A>digraph</A>.
A vertex <C>i</C> appears in the list <C>out</C> each time there exists an
edge with source <A>vertex</A> and range <C>i</C> in <A>digraph</A>; in
particular, this means that <C>out</C> may contain duplicates.<P/>
<Example><![CDATA[
gap> D := Digraph([
> [2, 2, 3], [1, 3, 4], [2, 2, 3], [1, 1, 2, 2, 1, 2, 2]]);
<immutable multidigraph with 4 vertices, 16 edges>
gap> OutNeighboursOfVertex(D, 1);
[ 2, 2, 3 ]
gap> OutNeighboursOfVertex(D, 3);
[ 2, 2, 3 ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="InDegreeOfVertex">
<ManSection>
<Oper Name="InDegreeOfVertex" Arg="digraph, vertex"/>
<Returns>A non-negative integer.</Returns>
<Description>
This operation returns the in-degree of the vertex <A>vertex</A> in the
digraph <A>digraph</A>.
The in-degree of <A>vertex</A> is the number of edges in <A>digraph</A>
whose range is <A>vertex</A>.
<Example><![CDATA[
gap> D := Digraph([
> [2, 2, 1], [1, 4], [2, 2, 4, 2], [1, 1, 2, 2, 1, 2, 2]]);
<immutable multidigraph with 4 vertices, 16 edges>
gap> InDegreeOfVertex(D, 1);
5
gap> InDegreeOfVertex(D, 2);
9
gap> InDegreeOfVertex(D, 3);
0
gap> InDegreeOfVertex(D, 4);
2
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="InNeighboursOfVertex">
<ManSection>
<Oper Name="InNeighboursOfVertex" Arg="digraph, vertex"/>
<Oper Name="InNeighborsOfVertex" Arg="digraph, vertex"/>
<Returns>A list of positive vertices.</Returns>
<Description>
This operation returns the list <C>inn</C> of vertices of the digraph
<A>digraph</A>.
A vertex <C>i</C> appears in the list <C>inn</C> each time there exists an
edge with source <C>i</C> and range <A>vertex</A> in <A>digraph</A>; in
particular, this means that <C>inn</C> may contain duplicates. <P/>
<Example><![CDATA[
gap> D := Digraph([
> [2, 2, 3], [1, 3, 4], [2, 2, 3], [1, 1, 2, 2, 1, 2, 2]]);
<immutable multidigraph with 4 vertices, 16 edges>
gap> InNeighboursOfVertex(D, 1);
[ 2, 4, 4, 4 ]
gap> InNeighboursOfVertex(D, 2);
[ 1, 1, 3, 3, 4, 4, 4, 4 ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphInEdges">
<ManSection>
<Oper Name="DigraphInEdges" Arg="digraph, vertex"/>
<Returns>A list of edges.</Returns>
<Description>
<C>DigraphInEdges</C> returns the list of all edges of <A>digraph</A>
which have <A>vertex</A> as their range.
<Example><![CDATA[
gap> D := Digraph([[2, 2], [3, 3], [4, 4], [1, 1]]);
<immutable multidigraph with 4 vertices, 8 edges>
gap> DigraphInEdges(D, 2);
[ [ 1, 2 ], [ 1, 2 ] ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphOutEdges">
<ManSection>
<Oper Name="DigraphOutEdges" Arg="digraph, vertex"/>
<Returns>A list of edges.</Returns>
<Description>
<C>DigraphOutEdges</C> returns the list of all edges of <A>digraph</A>
which have <A>vertex</A> as their source.
<Example><![CDATA[
gap> D := Digraph([[2, 2], [3, 3], [4, 4], [1, 1]]);
<immutable multidigraph with 4 vertices, 8 edges>
gap> DigraphOutEdges(D, 2);
[ [ 2, 3 ], [ 2, 3 ] ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphStronglyConnectedComponent">
<ManSection>
<Oper Name="DigraphStronglyConnectedComponent" Arg="digraph, vertex"/>
<Returns>A list of vertices.</Returns>
<Description>
If <A>vertex</A> is a vertex in the digraph <A>digraph</A>, then
this operation returns the strongly connected component of <A>vertex</A>
in <A>digraph</A>.
See <Ref Attr="DigraphStronglyConnectedComponents"/> for more information.
<Example><![CDATA[
gap> D := Digraph([[3], [2], [1, 2], [3]]);
<immutable digraph with 4 vertices, 5 edges>
gap> DigraphStronglyConnectedComponent(D, 3);
[ 1, 3 ]
gap> DigraphStronglyConnectedComponent(D, 2);
[ 2 ]
gap> DigraphStronglyConnectedComponent(D, 4);
[ 4 ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphConnectedComponent">
<ManSection>
<Oper Name="DigraphConnectedComponent" Arg="digraph, vertex"/>
<Returns>A list of vertices.</Returns>
<Description>
If <A>vertex</A> is a vertex in the digraph <A>digraph</A>, then
this operation returns the connected component of <A>vertex</A>
in <A>digraph</A>.
See <Ref Attr="DigraphConnectedComponents"/> for more information.
<Example><![CDATA[
gap> D := Digraph([[3], [2], [1, 2], [4]]);
<immutable digraph with 4 vertices, 5 edges>
gap> DigraphConnectedComponent(D, 3);
[ 1, 2, 3 ]
gap> DigraphConnectedComponent(D, 2);
[ 1, 2, 3 ]
gap> DigraphConnectedComponent(D, 4);
[ 4 ]
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="QuotientDigraph">
<ManSection>
<Oper Name="QuotientDigraph" Arg="digraph, p"/>
<Returns>A digraph.</Returns>
<Description>
If <A>digraph</A> is a digraph, and <A>p</A> is a partition of the vertices
of <A>digraph</A>, then this operation returns a digraph constructed by
amalgamating all vertices of <A>digraph</A> which lie in the same part of
<A>p</A>.
<P/>
A partition of the vertices of <A>digraph</A> is a list of non-empty
disjoint lists, such that the union of all the sub-lists is equal
to vertex set of <A>digraph</A>. In particular, each vertex must appear
in precisely one sub-list.
<P/>
The vertices of <A>digraph</A> in part <C>i</C> of <A>p</A> will become
vertex <C>i</C> in the quotient, and there exists some edge in <A>digraph</A>
with source in part <C>i</C> and range in part <C>j</C> if and only if there
is an edge from <C>i</C> to <C>j</C> in the quotient.
In particular, this means that the quotient of a digraph has no multiple edges.
which was a change introduced in version 1.0.0 of the &Digraphs; package.
<P/>
If <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>, then
<A>digraph</A> is modified in place. If <A>digraph</A> belongs to <Ref
Filt="IsImmutableDigraph"/>, a new immutable digraph with the above
properties is returned.<P/>
<Example><![CDATA[
gap> D := Digraph([[2, 1], [4], [1], [1, 3, 4]]);
<immutable digraph with 4 vertices, 7 edges>
gap> DigraphVertices(D);
[ 1 .. 4 ]
gap> DigraphEdges(D);
[ [ 1, 2 ], [ 1, 1 ], [ 2, 4 ], [ 3, 1 ], [ 4, 1 ], [ 4, 3 ],
[ 4, 4 ] ]
gap> p := [[1], [2, 4], [3]];
[ [ 1 ], [ 2, 4 ], [ 3 ] ]
gap> quo := QuotientDigraph(D, p);
<immutable digraph with 3 vertices, 6 edges>
gap> DigraphVertices(quo);
[ 1 .. 3 ]
gap> DigraphEdges(quo);
[ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 1 ] ]
gap> QuotientDigraph(EmptyDigraph(0), []);
<immutable empty digraph with 0 vertices>
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="IsDigraphEdge">
<ManSection>
<Oper Name="IsDigraphEdge" Arg="digraph, list"
Label="for digraph and list"/>
<Oper Name="IsDigraphEdge" Arg="digraph, u, v"
Label="for digraph and two pos ints"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
In the first form, this function returns <K>true</K> if and only if the list
<A>list</A> specifies an edge in the digraph <A>digraph</A>. Specifically,
this operation returns <K>true</K> if <A>list</A> is a pair of positive
integers where <A>list</A><C>[1]</C> is the source and <A>list</A><C>[2]</C>
is the range of an edge in <A>digraph</A>, and <K>false</K> otherwise. <P/>
The second form simply returns <K>true</K> if <C>[<A>u</A>, <A>v</A>]</C> is
an edge in <A>digraph</A>, and <K>false</K> otherwise.
<Example><![CDATA[
gap> D := Digraph([[2, 2], [6], [], [3], [], [1]]);
<immutable multidigraph with 6 vertices, 5 edges>
gap> IsDigraphEdge(D, [1, 1]);
false
gap> IsDigraphEdge(D, [1, 2]);
true
gap> IsDigraphEdge(D, [1, 8]);
false
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
<#GAPDoc Label="DigraphFloydWarshall">
<ManSection>
<Oper Name="DigraphFloydWarshall" Arg="digraph, func, nopath, edge"/>
<Returns>A matrix.</Returns>
<Description>
If <A>digraph</A> is a digraph with <M>n</M> vertices, then
this operation returns an <M>n \times n</M> matrix <C>mat</C> containing
the output of a generalised version of the Floyd-Warshall algorithm,
applied to <A>digraph</A>. <P/>
The operation <C>DigraphFloydWarshall</C> is customised by the arguments
<A>func</A>, <A>nopath</A>, and <A>edge</A>.
The arguments <A>nopath</A> and <A>edge</A> can be arbitrary &GAP; objects.
The argument <A>func</A> must be a function which accepts 4 arguments:
the matrix <C>mat</C>, followed by 3 positive integers. The function
<A>func</A> is where the work to calculate the desired outcome must be
performed. <P/>
This method initialises the matrix <C>mat</C> by setting entry
<C>mat[i][j]</C> to equal <A>edge</A> if there is an edge with source
<C>i</C> and range <C>j</C>, and by setting entry <C>mat[i][j]</C> to equal