Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/digraphs/tst/standard/   (GAP Algebra Version 4.15.1©)  Datei vom 27.8.2025 mit Größe 116 kB image not shown  

Quelle  oper.tst   Sprache: unbekannt

 
Spracherkennung für: .tst vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

#############################################################################
##
#W  standard/oper.tst
#Y  Copyright (C) 2014-17                                James D. Mitchell
##                                                          Wilf A. Wilson
##
##  Licensing information can be found in the README file of this package.
##
#############################################################################
##

#@local C, D, D1, D2, D3, D3_edges, DD
#@local G, G1, L, TestPartialOrderDigraph
#@local TestPartialOrderDigraph2, TestUnion, a, adj, b, comps, copy, d, e
#@local edges, edges2, func, g, gr, gr1, gr2, gr3, gr4, gri, grrt, grt, h, i
#@local i1, i2, id, idom, in1, in2, in3, iter, j1, j2, m, m1, m2, mat, n, nbs
#@local out, out1, out2, out3, p1, p2, path, preorder, qr, r, res, rtclosure, t
#@local tclosure, u1, u2, x
gap> START_TEST("Digraphs package: standard/oper.tst");
gap> LoadPackage("digraphs", false);;

#
gap> DIGRAPHS_StartTest();

#  DigraphIsKing: for a digraph, a node and a positive integer
gap> gr := Digraph([[2], [34], [14], [1]]);
<immutable digraph with 4 vertices, 6 edges>
gap> IsTournament(gr);
true
gap> DigraphIsKing(gr, 22);
true
gap> DigraphIsKing(gr, 42);
false
gap> DigraphIsKing(gr, 43);
true
gap> DigraphIsKing(gr, 52);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> gr := Digraph([[], [34], [14], [1]]);
<immutable digraph with 4 vertices, 5 edges>
gap> DigraphIsKing(gr, 22);
Error, the 1st argument <D> must be a tournament,

#  DigraphRemoveLoops
gap> gr := DigraphFromDigraph6String("&EhxPC?@");
<immutable digraph with 6 vertices, 11 edges>
gap> DigraphRemoveLoops(gr);
<immutable digraph with 6 vertices, 7 edges>
gap> gr := DigraphFromDigraph6String("&EhxPC?@");
<immutable digraph with 6 vertices, 11 edges>
gap> HasDigraphHasLoops(gr);
false
gap> DigraphHasLoops(gr);
true
gap> gr1 := DigraphRemoveLoops(gr);
<immutable digraph with 6 vertices, 7 edges>
gap> HasDigraphHasLoops(gr1);
true
gap> DigraphHasLoops(gr1);
false

#  DigraphRemoveEdges: for a list of edges
gap> gr := Digraph([[2], []]);
<immutable digraph with 2 vertices, 1 edge>
gap> DigraphRemoveEdges(gr, [[21]]);
<immutable digraph with 2 vertices, 1 edge>
gap> last = gr;
true
gap> DigraphRemoveEdges(gr, [[12]]);
<immutable empty digraph with 2 vertices>
gap> gr := DigraphFromDigraph6String("&DtGsw_");
<immutable digraph with 5 vertices, 12 edges>
gap> Set(DigraphEdges(gr)) = Set(
> [[12], [11], [14], [21], [24], [34],
>  [33], [41], [45], [44], [51], [55]]);
true
gap> gr1 := DigraphRemoveEdges(gr, [[14], [45], [55]]);
<immutable digraph with 5 vertices, 9 edges>
gap> DigraphEdges(gr1);
[ [ 12 ], [ 11 ], [ 21 ], [ 24 ], [ 34 ], [ 33 ], [ 41 ], 
  [ 44 ], [ 51 ] ]
gap> gr := Digraph([[22], []]);
<immutable multidigraph with 2 vertices, 2 edges>
gap> DigraphRemoveEdges(gr, [[12]]);
Error, the 1st argument <D> must be a digraph with no multiple edges,

#  DigraphRemoveEdge: for an edge
gap> gr := Digraph([[11]]);
<immutable multidigraph with 1 vertex, 2 edges>
gap> DigraphRemoveEdge(gr, [11]);
Error, the 1st argument <D> must be a digraph with no multiple edges,
gap> gr := Digraph([[2], [1]]);
<immutable digraph with 2 vertices, 2 edges>
gap> DigraphRemoveEdge(gr, [111]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphRemoveEdge(gr, [Group(()), Group(())]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphRemoveEdge' on 3 arguments
gap> DigraphRemoveEdge(gr, [1, Group(())]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphRemoveEdge' on 3 arguments
gap> DigraphRemoveEdge(gr, [31]);
Error, the 2nd argument <src> must be a vertex of the digraph <D> that is the \
1st argument,
gap> DigraphRemoveEdge(gr, [13]);
Error, the 3rd argument <ran> must be a vertex of the digraph <D> that is the \
1st argument,
gap> gr := DigraphRemoveEdge(gr, [21]);
<immutable digraph with 2 vertices, 1 edge>
gap> DigraphEdges(gr);
[ [ 12 ] ]

#  OnDigraphs: for a digraph and a perm
gap> gr := Digraph([[2], [1], [3]]);
<immutable digraph with 3 vertices, 3 edges>
gap> DigraphEdges(gr);
[ [ 12 ], [ 21 ], [ 33 ] ]
gap> g := (123);
(1,2,3)
gap> OnDigraphs(gr, g);
<immutable digraph with 3 vertices, 3 edges>
gap> DigraphEdges(last);
[ [ 11 ], [ 23 ], [ 32 ] ]
gap> h := (1234);
(1,2,3,4)
gap> OnDigraphs(gr, h);
Error, the 2nd argument <p> must be a permutation that permutes the vertices o\
f the digraph <D> that is the 1st argument
gap> gr := Digraph([[11135], [], [3245], [25], [121]]);
<immutable multidigraph with 5 vertices, 14 edges>
gap> DigraphEdges(gr);
[ [ 11 ], [ 11 ], [ 11 ], [ 13 ], [ 15 ], [ 33 ], [ 32 ], 
  [ 34 ], [ 35 ], [ 42 ], [ 45 ], [ 51 ], [ 52 ], [ 51 ] ]
gap> p1 := (24)(365);
(2,4)(3,6,5)
gap> OnDigraphs(gr, p1);
Error, the 2nd argument <p> must be a permutation that permutes the vertices o\
f the digraph <D> that is the 1st argument
gap> p2 := (1342);
(1,3,4,2)
gap> OnDigraphs(gr, p2);
<immutable multidigraph with 5 vertices, 14 edges>
gap> DigraphEdges(last);
[ [ 21 ], [ 25 ], [ 33 ], [ 33 ], [ 33 ], [ 34 ], [ 35 ], 
  [ 44 ], [ 41 ], [ 42 ], [ 45 ], [ 53 ], [ 51 ], [ 53 ] ]
gap> gr := DigraphFromDiSparse6String(".CaoJG_hF");
<immutable multidigraph with 4 vertices, 8 edges>
gap> DigraphEdges(gr);
[ [ 12 ], [ 13 ], [ 21 ], [ 24 ], [ 24 ], [ 33 ], [ 41 ], 
  [ 43 ] ]
gap> p1 := (15423);
(1,5,4,2,3)
gap> OnDigraphs(gr, p1);
Error, the 2nd argument <p> must be a permutation that permutes the vertices o\
f the digraph <D> that is the 1st argument
gap> p2 := (14)(23);
(1,4)(2,3)
gap> OnDigraphs(gr, p2);
<immutable multidigraph with 4 vertices, 8 edges>
gap> DigraphEdges(last);
[ [ 14 ], [ 12 ], [ 22 ], [ 34 ], [ 31 ], [ 31 ], [ 43 ], 
  [ 42 ] ]

#  OnDigraphs: for a digraph and a transformation
gap> gr := Digraph([[2], [13], []]);
<immutable digraph with 3 vertices, 3 edges>
gap> OutNeighbours(gr);
[ [ 2 ], [ 13 ], [  ] ]
gap> t := Transformation([4234]);;
gap> OnDigraphs(gr, t);
Error, the 2nd argument <t> must be a transformation that maps every vertex of\
 the digraph <D> that is the 1st argument, to another vertex
gap> t := Transformation([121]);;
gap> gr := OnDigraphs(gr, t);
<immutable multidigraph with 3 vertices, 3 edges>
gap> OutNeighbours(gr);
[ [ 2 ], [ 11 ], [  ] ]

#  OnTuplesDigraphs: for a digraph and a permutation
gap> D := [ChainDigraph(3), CycleDigraph(4)];;
gap> List(D, OutNeighbours);
[ [ [ 2 ], [ 3 ], [  ] ], [ [ 2 ], [ 3 ], [ 4 ], [ 1 ] ] ]
gap> List(OnTuplesDigraphs(D, (13)), OutNeighbours);
[ [ [  ], [ 1 ], [ 2 ] ], [ [ 4 ], [ 1 ], [ 2 ], [ 3 ] ] ]
gap> D := [ChainDigraph(3), DigraphReverse(ChainDigraph(3))];;
gap> List(D, OutNeighbours);
[ [ [ 2 ], [ 3 ], [  ] ], [ [  ], [ 1 ], [ 2 ] ] ]
gap> List(OnTuplesDigraphs(D, (13)), OutNeighbours);
[ [ [  ], [ 1 ], [ 2 ] ], [ [ 2 ], [ 3 ], [  ] ] ]
gap> OnTuplesDigraphs(D, (13)) = Permuted(D, (12));
true
gap> D := EmptyDigraph(IsMutableDigraph, 3);;
gap> DigraphAddEdge(D, 11);;
gap> out := OnTuplesDigraphs([D, D], (123));;
gap> List(out, DigraphEdges);
[ [ [ 22 ] ], [ [ 22 ] ] ]

#  OnSetsDigraphs: for a digraph and a permutation
gap> D := [DigraphReverse(ChainDigraph(3)), ChainDigraph(3)];;
gap> IsSet(D);
false
gap> OnSetsDigraphs(D, (12));
Error, the first argument must be a set (a strictly sorted list)
gap> D := Reversed(D);;
gap> OnSetsDigraphs(D, (13)) = D;
true
gap> OnSetsDigraphs(D, (13)) = OnTuplesDigraphs(D, (13));
false
gap> MinimalGeneratingSet(Stabilizer(SymmetricGroup(3), D, OnSetsDigraphs));
[ (1,3) ]

# Set of orbital graphs of G := TransitiveGroup(64)
# The stabiliser of this set is the normaliser of G in S_6
gap> x := Set(["&ECA@_OG", "&EQHcQHc", "&EHcQHcQ"], DigraphFromDigraph6String);
[ <immutable digraph with 6 vertices, 6 edges>, 
  <immutable digraph with 6 vertices, 12 edges>, 
  <immutable digraph with 6 vertices, 12 edges> ]
gap> Stabiliser(SymmetricGroup(6), x, OnSetsDigraphs)
> = Group([(123456), (15)(24)(36)]);
true
gap> OnTuplesDigraphs(x, (23)(56)) = x;
false
gap> OnTuplesDigraphs(x, (23)(56)) = [x[1], x[3], x[2]];
true
gap> OnSetsDigraphs(x, (23)(56)) = x;
true

#  OnMultiDigraphs: for a pair of permutations
gap> gr1 := CompleteDigraph(3);
<immutable complete digraph with 3 vertices>
gap> DigraphEdges(gr1);
[ [ 12 ], [ 13 ], [ 21 ], [ 23 ], [ 31 ], [ 32 ] ]
gap> gr2 := OnMultiDigraphs(gr1, (13), (36));;
gap> DigraphEdges(gr1);;
gap> OnMultiDigraphs(gr1, [(13)]);
Error, the 2nd argument <perms> must be a pair of permutations,
gap> OnMultiDigraphs(gr1, [(13), (17)]);
Error, the 2nd entry of the 2nd argument <perms> must permute the edges of the\
 digraph <D> that is the 1st argument

#  DomainForAction
gap> DomainForAction(RandomDigraph(10), SymmetricGroup(10), OnDigraphs);
true

#  InNeighboursOfVertex and InDegreeOfVertex
gap> gr := DigraphFromDiSparse6String(".IgBGLQ?Apkc");
<immutable multidigraph with 10 vertices, 6 edges>
gap> InNeighborsOfVertex(gr, 7);
7 ]
gap> InNeighboursOfVertex(gr, 7);
7 ]
gap> InDegreeOfVertex(gr, 7);
1
gap> InNeighboursOfVertex(gr, 11);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> InDegreeOfVertex(gr, 11);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> gr := DigraphFromDiSparse6String(".CgXo?eWCaJ");
<immutable multidigraph with 4 vertices, 11 edges>
gap> InNeighboursOfVertex(gr, 3);
2 ]
gap> InDegreeOfVertex(gr, 3);
1
gap> InNeighbours(gr);
[ [ 11 ], [ 234 ], [ 2 ], [ 12333 ] ]
gap> InNeighboursOfVertex(gr, 4);
12333 ]
gap> InDegreeOfVertex(gr, 4);
5
gap> InDegrees(gr);
2315 ]
gap> InDegreeOfVertex(gr, 2);
3

#  OutNeighboursOfVertex and OutDegreeOfVertex
gap> gr := DigraphFromDiSparse6String(".Ig??OaDgDQ~");
<immutable multidigraph with 10 vertices, 8 edges>
gap> OutNeighborsOfVertex(gr, 2);
[  ]
gap> OutNeighboursOfVertex(gr, 2);
[  ]
gap> OutDegreeOfVertex(gr, 2);
0
gap> OutNeighboursOfVertex(gr, 5);
112233 ]
gap> OutDegreeOfVertex(gr, 5);
6
gap> OutNeighboursOfVertex(gr, 12);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> OutDegreeOfVertex(gr, 12);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> gr := Digraph([[2222], [22]]);
<immutable multidigraph with 2 vertices, 6 edges>
gap> OutNeighboursOfVertex(gr, 2);
22 ]
gap> OutDegreeOfVertex(gr, 2);
2
gap> OutDegrees(gr);
42 ]
gap> OutDegreeOfVertex(gr, 1);
4

#  InducedSubdigraph
gap> r := rec(DigraphNrVertices := 8,
> DigraphSource := [11111122233555555],
> DigraphRange := [11233411345134457]);;
gap> gr := Digraph(r);
<immutable multidigraph with 8 vertices, 17 edges>
gap> InducedSubdigraph(gr, [-1]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> InducedSubdigraph(gr, [1 .. 9]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> InducedSubdigraph(gr, []);
<immutable empty digraph with 0 vertices>
gap> InducedSubdigraph(gr, [2 .. 6]);
<immutable multidigraph with 5 vertices, 7 edges>
gap> InducedSubdigraph(gr, [8]);
<immutable empty digraph with 1 vertex>
gap> i1 := InducedSubdigraph(gr, [143]);
<immutable multidigraph with 3 vertices, 6 edges>
gap> OutNeighbours(i1);
[ [ 11332 ], [  ], [ 2 ] ]
gap> i2 := InducedSubdigraph(gr, [3431]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> adj := [[2345667], [111345], [4], [35],
> [1223446567], [], [1], []];;
gap> gr := Digraph(adj);
<immutable multidigraph with 8 vertices, 27 edges>
gap> InducedSubdigraph(gr, ["a"]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> InducedSubdigraph(gr, [0]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> InducedSubdigraph(gr, [2 .. 9]);
Error, the 2nd argument <list> must be a duplicate-free subset of the vertices\
 of the digraph <D> that is the 1st argument,
gap> InducedSubdigraph(gr, []);
<immutable empty digraph with 0 vertices>
gap> i1 := InducedSubdigraph(gr, [1357]);
<immutable digraph with 4 vertices, 8 edges>
gap> OutNeighbours(i1);
[ [ 234 ], [  ], [ 1234 ], [ 1 ] ]
gap> i2 := InducedSubdigraph(gr, [7531]);
<immutable digraph with 4 vertices, 8 edges>
gap> i1 = i2;
false
gap> IsIsomorphicDigraph(i1, i2);
true
gap> InducedSubdigraph(gr, [2 .. 8]);
<immutable multidigraph with 7 vertices, 15 edges>
gap> InducedSubdigraph(gr, [8]);
<immutable empty digraph with 1 vertex>
gap> InducedSubdigraph(gr, [78]);
<immutable empty digraph with 2 vertices>
gap> gr := Digraph([[24], [45], [255], [55], [3]]);
<immutable multidigraph with 5 vertices, 10 edges>
gap> gri := InducedSubdigraph(gr, [425]);
<immutable multidigraph with 3 vertices, 4 edges>
gap> DigraphVertexLabels(gri);
425 ]
gap> OutNeighbours(gri);
[ [ 33 ], [ 13 ], [  ] ]

#  QuotientDigraph
gap> gr := CompleteDigraph(2);
<immutable complete digraph with 2 vertices>
gap> DigraphEdges(gr);
[ [ 12 ], [ 21 ] ]
gap> qr := QuotientDigraph(gr, [[12]]);
<immutable digraph with 1 vertex, 1 edge>
gap> DigraphEdges(qr);
[ [ 11 ] ]
gap> QuotientDigraph(EmptyDigraph(0), []);
<immutable empty digraph with 0 vertices>
gap> QuotientDigraph(EmptyDigraph(0), [[1]]);
Error, the 2nd argument <partition> should be an empty list, which is the only\
 valid partition of the vertices of 1st argument <D> because it has no vertice\
s,
gap> gr := Digraph([[1232], [132], [12]]);
<immutable multidigraph with 3 vertices, 9 edges>
gap> DigraphEdges(gr);
[ [ 11 ], [ 12 ], [ 13 ], [ 12 ], [ 21 ], [ 23 ], [ 22 ], 
  [ 31 ], [ 32 ] ]
gap> qr := QuotientDigraph(gr, [[13], [2]]);
<immutable digraph with 2 vertices, 4 edges>
gap> DigraphEdges(qr);
[ [ 11 ], [ 12 ], [ 21 ], [ 22 ] ]
gap> QuotientDigraph(gr, [3]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, []);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[], []]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[0], [1]]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[1], [2], [0]]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[1], [24]]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[12], [2]]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> QuotientDigraph(gr, [[1], [2]]);
Error, the 2nd argument <partition> is not a valid partition of the vertices [\
1 .. 3] of the 1st argument <D>,
gap> gr := Digraph(rec(
> DigraphNrVertices := 8,
> DigraphSource := [11223444555556777778,
>                   8],
> DigraphRange := [67165148134677145675,
>                  6]));
<immutable digraph with 8 vertices, 21 edges>
gap> qr := QuotientDigraph(gr, [[1], [2357], [468]]);
<immutable digraph with 3 vertices, 8 edges>
gap> OutNeighbours(qr);
[ [ 23 ], [ 123 ], [ 123 ] ]

#  DigraphInEdges and DigraphOutEdges: for a vertex
gap> gr := Digraph([[22222], [1111], [1], [32]]);
<immutable multidigraph with 4 vertices, 12 edges>
gap> DigraphInEdges(gr, 1);
[ [ 21 ], [ 21 ], [ 21 ], [ 21 ], [ 31 ] ]
gap> DigraphOutEdges(gr, 3);
[ [ 31 ] ]
gap> DigraphOutEdges(gr, 5);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> DigraphInEdges(gr, 1000);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,
gap> gr := Digraph(rec(DigraphVertices := ["a", "b", "c"],
>                      DigraphSource   := ["a", "a", "b"],
>                      DigraphRange    := ["b", "b", "c"]));
<immutable multidigraph with 3 vertices, 3 edges>
gap> DigraphInEdges(gr, 1);
[  ]
gap> DigraphInEdges(gr, 2);
[ [ 12 ], [ 12 ] ]
gap> DigraphOutEdges(gr, 1);
[ [ 12 ], [ 12 ] ]

#  DigraphStronglyConnectedComponent
gap> gr := Digraph([[24], [], [26], [13], [23], [5]]);
<immutable digraph with 6 vertices, 9 edges>
gap> DigraphStronglyConnectedComponent(gr, 1);
14 ]
gap> DigraphStronglyConnectedComponent(gr, 2);
2 ]
gap> DigraphStronglyConnectedComponent(gr, 3);
365 ]
gap> DigraphStronglyConnectedComponent(gr, 7);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,

#  DigraphyConnectedComponent
gap> gr := Digraph([[24], [], [26], [13], [23], [5]]);
<immutable digraph with 6 vertices, 9 edges>
gap> DigraphConnectedComponent(gr, 3);
123456 ]
gap> DigraphConnectedComponent(gr, 7);
Error, the 2nd argument <v> is not a vertex of the 1st argument <D>,

#  IsDigraphEdge

# CycleDigraph with source/range
gap> gr := CycleDigraph(1000);
<immutable cycle digraph with 1000 vertices>
gap> IsDigraphEdge(gr, [1]);
false
gap> IsDigraphEdge(gr, ["a", 2]);
false
gap> IsDigraphEdge(gr, [1, "a"]);
false
gap> IsDigraphEdge(gr, [10011]);
false
gap> IsDigraphEdge(gr, [11001]);
false
gap> IsDigraphEdge(gr, [100101]);
true
gap> IsDigraphEdge(gr, [10001]);
true
gap> IsDigraphEdge(gr, [1000600]);
false
gap> out := List([1 .. 999], x -> [x + 1]);;
gap> Add(out, [1]);;

# CycleDigraph with OutNeighbours
gap> gr := Digraph(out);
<immutable digraph with 1000 vertices, 1000 edges>
gap> IsDigraphEdge(gr, [1]);
false
gap> IsDigraphEdge(gr, ["a", 2]);
false
gap> IsDigraphEdge(gr, [1, "a"]);
false
gap> IsDigraphEdge(gr, [10011]);
false
gap> IsDigraphEdge(gr, [11001]);
false
gap> IsDigraphEdge(gr, [100101]);
true
gap> IsDigraphEdge(gr, [10001]);
true
gap> IsDigraphEdge(gr, [1000600]);
false
gap> gr := Digraph(rec(DigraphNrVertices := 2,
>                      DigraphSource     := [1],
>                      DigraphRange      := [2]));
<immutable digraph with 2 vertices, 1 edge>
gap> IsDigraphEdge(gr, [21]);
false
gap> IsDigraphEdge(gr, [11]);
false

# A bigger digraph with OutNeighbours
gap> gr := CompleteDigraph(500);
<immutable complete digraph with 500 vertices>
gap> IsDigraphEdge(gr, [200199]);
true
gap> IsDigraphEdge(gr, [499499]);
false
gap> IsDigraphEdge(gr, [249251]);
true
gap> gr := EmptyDigraph(1000000);
<immutable empty digraph with 1000000 vertices>
gap> IsDigraphEdge(gr, [99999999]);
false
gap> gr := CompleteDigraph(10);
<immutable complete digraph with 10 vertices>
gap> mat := AdjacencyMatrix(gr);;
gap> IsDigraphEdge(gr, [55]);
false
gap> IsDigraphEdge(gr, [56]);
true
gap> gr := Digraph([[11], [2]]);
<immutable multidigraph with 2 vertices, 3 edges>
gap> mat := AdjacencyMatrix(gr);;
gap> IsDigraphEdge(gr, [11]);
true
gap> IsDigraphEdge(gr, [12]);
false

# Adjacency function
gap> adj := function(i, j) return i = j * 2; end;
function( i, j ) ... end
gap> gr := Digraph([1 .. 20], adj);;
gap> IsDigraphEdge(gr, [14]);
false
gap> IsDigraphEdge(gr, 36);
false
gap> IsDigraphEdge(gr, 126);
true
gap> IsDigraphEdge(gr, 2613);
false

#  DigraphAddEdges
gap> gr := RandomDigraph(100);;
gap> DigraphAddEdges(gr, []);;
gap> gr = last;
true
gap> DigraphAddEdges(gr, [12]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 2 arguments
gap> DigraphAddEdges(gr, [[12]]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdges(gr, [[121314], [1110]]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdges(gr, [[-23], ["a"]]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 3 arguments
gap> DigraphAddEdges(gr, [[1110], [121314]]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdges(gr, [[45], [1120], [11]]);
Error, the 2nd argument <ran> must be a vertex of the digraph <D> that is the \
1st argument,
gap> DigraphAddEdges(gr, [[45], [1201], [11]]);
Error, the 2nd argument <src> must be a vertex of the digraph <D> that is the \
1st argument,
gap> gr := Digraph([[22], [132], [21], [1]]);
<immutable multidigraph with 4 vertices, 8 edges>
gap> DigraphEdges(gr);
[ [ 12 ], [ 12 ], [ 21 ], [ 23 ], [ 22 ], [ 32 ], [ 31 ], 
  [ 41 ] ]
gap> gr2 := DigraphAddEdges(gr, [[21], [33], [24], [33]]);
<immutable multidigraph with 4 vertices, 12 edges>
gap> DigraphEdges(gr2);
[ [ 12 ], [ 12 ], [ 21 ], [ 23 ], [ 22 ], [ 21 ], [ 24 ], 
  [ 32 ], [ 31 ], [ 33 ], [ 33 ], [ 41 ] ]
gap> gr3 := Digraph(rec(DigraphNrVertices := DigraphNrVertices(gr),
>                         DigraphSource := ShallowCopy(DigraphSource(gr)),
>                         DigraphRange := ShallowCopy(DigraphRange(gr))));
<immutable multidigraph with 4 vertices, 8 edges>
gap> gr4 := DigraphAddEdges(gr3, [[21], [33], [24], [33]]);
<immutable multidigraph with 4 vertices, 12 edges>
gap> gr2 = gr4;
true
gap> gr := Digraph([[12], [], [1]]);
<immutable digraph with 3 vertices, 3 edges>
gap> gr1 := DigraphAddEdges(gr, []);
<immutable digraph with 3 vertices, 3 edges>
gap> gr = gr1;
true
gap> DigraphAddEdges(gr, [3]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 2 arguments
gap> DigraphAddEdges(gr, [[3]]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdges(gr, ["ab"]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 3 arguments
gap> DigraphAddEdges(gr, [[-1, -2]]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 3 arguments
gap> DigraphAddEdges(gr, [[12], [123]]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdges(gr, [[42]]);
Error, the 2nd argument <src> must be a vertex of the digraph <D> that is the \
1st argument,
gap> DigraphAddEdges(gr, [[24]]);
Error, the 2nd argument <ran> must be a vertex of the digraph <D> that is the \
1st argument,
gap> DigraphAddEdges(gr, [[23], [23]]);
<immutable multidigraph with 3 vertices, 5 edges>
gap> DigraphEdges(last);
[ [ 11 ], [ 12 ], [ 23 ], [ 23 ], [ 31 ] ]
gap> DigraphEdges(gr);
[ [ 11 ], [ 12 ], [ 31 ] ]

#  DigraphAddEdge
gap> gr := RandomDigraph(10);;
gap> DigraphAddEdge(gr, [123]);
Error, the 2nd argument <edge> must be a list of length 2,
gap> DigraphAddEdge(gr, ["a", "a"]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 3 arguments
gap> DigraphAddEdge(gr, [1, "a"]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphAddEdge' on 3 arguments
gap> DigraphAddEdge(gr, [111]);
Error, the 2nd argument <src> must be a vertex of the digraph <D> that is the \
1st argument,
gap> DigraphAddEdge(gr, [111]);
Error, the 2nd argument <ran> must be a vertex of the digraph <D> that is the \
1st argument,
gap> gr := EmptyDigraph(2);
<immutable empty digraph with 2 vertices>
gap> DigraphAddEdge(gr, [12]);
<immutable digraph with 2 vertices, 1 edge>
gap> DigraphEdges(last);
[ [ 12 ] ]
gap> n := 10 ^ 5;; D1 := EmptyDigraph(IsMutableDigraph, n);;
gap> for i in [1 .. n - 1] do DigraphAddEdge(D1, i, i + 1); od;
gap> D1 = ChainDigraph(n);
true

#  DigraphAddVertices
gap> gr := Digraph([[1]]);;
gap> gr2 := DigraphAddVertices(gr, 3);
<immutable digraph with 4 vertices, 1 edge>
gap> DigraphVertices(gr2);
1 .. 4 ]
gap> DigraphEdges(gr) = DigraphEdges(gr2);
true
gap> gr2 := DigraphAddVertices(gr, [SymmetricGroup(2), Group(())]);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertices(gr2);
1 .. 3 ]
gap> DigraphEdges(gr) = DigraphEdges(gr2);
true
gap> DigraphVertexLabels(gr2);
1, Sym( [ 1 .. 2 ] ), Group(()) ]
gap> gr := Digraph([[1]]);;
gap> SetDigraphVertexLabels(gr, [AlternatingGroup(5)]);
gap> gr2 := DigraphAddVertices(gr, [SymmetricGroup(2), Group(())]);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(gr2);
[ Alt( [ 1 .. 5 ] ), Sym( [ 1 .. 2 ] ), Group(()) ]
gap> gr := Digraph(rec(DigraphNrVertices := 1,
>                      DigraphSource     := [1],
>                      DigraphRange      := [1]));
<immutable digraph with 1 vertex, 1 edge>
gap> gr2 := DigraphAddVertices(gr, 2);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(gr2);
123 ]
gap> SetDigraphVertexLabels(gr, [true]);
gap> gr2 := DigraphAddVertices(gr, 2);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(gr2);
[ true, 23 ]
gap> gr := Digraph(rec(DigraphNrVertices := 1,
>                      DigraphSource     := [1],
>                      DigraphRange      := [1]));;
gap> gr2 := DigraphAddVertices(gr, [SymmetricGroup(2), Group(())]);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(gr2);
1, Sym( [ 1 .. 2 ] ), Group(()) ]
gap> gr := Digraph(rec(DigraphNrVertices := 1,
>                      DigraphSource     := [1],
>                      DigraphRange      := [1]));;
gap> SetDigraphVertexLabels(gr, [AlternatingGroup(5)]);
gap> gr2 := DigraphAddVertices(gr, [SymmetricGroup(2), Group(())]);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(gr2);
[ Alt( [ 1 .. 5 ] ), Sym( [ 1 .. 2 ] ), Group(()) ]
gap> DigraphAddVertices(gr2, -1);
Error, the 2nd argument <m> must be a non-negative integer,
gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, 0));
true
gap> IsIdenticalObj(gr2, DigraphAddVertices(gr2, []));
true

#  DigraphAddVertices (redundant three-argument version)
gap> D := Digraph([[1]]);
<immutable digraph with 1 vertex, 1 edge>
gap> DigraphVertexLabels(D);
1 ]
gap> DigraphAddVertices(D, 2, [fail]);
Error, the list <labels> (3rd argument) must have length <m> (2nd argument),
gap> D := DigraphAddVertices(D, 2, [fail, true]);
<immutable digraph with 3 vertices, 1 edge>
gap> DigraphVertexLabels(D);
1, fail, true ]

#  DigraphAddVertex
gap> gr := CompleteDigraph(1);
<immutable empty digraph with 1 vertex>
gap> DigraphVertices(gr);
1 ]
gap> gr2 := DigraphAddVertex(gr);
<immutable empty digraph with 2 vertices>
gap> DigraphVertices(gr2);
12 ]
gap> DigraphEdges(gr) = DigraphEdges(gr2);
true
gap> gr := DigraphAddEdge(gr, [11]);
<immutable digraph with 1 vertex, 1 edge>
gap> DigraphVertices(gr);
1 ]
gap> gr2 := DigraphAddVertex(gr);
<immutable digraph with 2 vertices, 1 edge>
gap> DigraphVertices(gr2);
12 ]
gap> DigraphEdges(gr) = DigraphEdges(gr2);
true
gap> gr2 := DigraphAddVertex(gr, SymmetricGroup(2));
<immutable digraph with 2 vertices, 1 edge>
gap> DigraphVertices(gr2);
12 ]
gap> DigraphEdges(gr) = DigraphEdges(gr2);
true
gap> DigraphVertexLabels(gr);
1 ]
gap> DigraphVertexLabels(gr2);
1, Sym( [ 1 .. 2 ] ) ]

#  DigraphRemoveVertex
gap> gr := DigraphFromDigraph6String("&MU?GAa?SDCFStK`???d?@LWOq[{DECO?U?");
<immutable digraph with 14 vertices, 54 edges>
gap> DigraphRemoveVertex(gr, "a");
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphRemoveVertex' on 2 arguments
gap> DigraphRemoveVertex(gr, 0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphRemoveVertex' on 2 arguments
gap> DigraphRemoveVertex(gr, 15);
<immutable digraph with 14 vertices, 54 edges>
gap> gr2 := DigraphRemoveVertex(gr, 10);;
gap> DigraphNrVertices(gr2);
13
gap> DigraphNrEdges(gr2) =
> DigraphNrEdges(gr) - OutDegreeOfVertex(gr, 10) - InDegreeOfVertex(gr, 10);
true
gap> D := CycleDigraph(IsMutableDigraph, 5);
<mutable digraph with 5 vertices, 5 edges>
gap> DigraphRemoveVertex(D, 1);
<mutable digraph with 4 vertices, 3 edges>
gap> DigraphVertexLabels(D);
2345 ]

#  DigraphRemoveVertices
gap> gr := CompleteDigraph(4);
<immutable complete digraph with 4 vertices>
gap> gr2 := DigraphRemoveVertices(gr, []);
<immutable digraph with 4 vertices, 12 edges>
gap> gr = gr2;
true
gap> gr2 := DigraphRemoveVertices(gr, [0]);
Error, the 2nd argument <list> must be a duplicate-free list of positive integ\
ers,
gap> gr2 := DigraphRemoveVertices(gr, [1, "a"]);
Error, the 2nd argument <list> must be a duplicate-free list of positive integ\
ers,
gap> gr2 := DigraphRemoveVertices(gr, [11]);
Error, the 2nd argument <list> must be a duplicate-free list of positive integ\
ers,
gap> gr2 := DigraphRemoveVertices(gr, [10]);
Error, the 2nd argument <list> must be a duplicate-free list of positive integ\
ers,
gap> gr2 := DigraphRemoveVertices(gr, [15]);
<immutable digraph with 3 vertices, 6 edges>
gap> gr2 := DigraphRemoveVertices(gr, [13]);
<immutable digraph with 2 vertices, 2 edges>
gap> IsCompleteDigraph(gr2);
true
gap> DigraphVertexLabels(gr2);
24 ]
gap> gr3 := DigraphRemoveVertices(gr, [1 .. 4]);
<immutable empty digraph with 0 vertices>
gap> gr := Digraph(rec(DigraphNrVertices := 4,
> DigraphSource := [1111222233334444],
> DigraphRange := [1234123412341234]));
<immutable digraph with 4 vertices, 16 edges>
gap> IsCompleteDigraph(gr);
false
gap> SetDigraphVertexLabels(gr, [(), (12), (123), (1234)]);
gap> gr2 := DigraphRemoveVertices(gr, [1 .. 4]);
<immutable empty digraph with 0 vertices>
gap> gr3 := DigraphRemoveVertices(gr, [23]);
<immutable digraph with 2 vertices, 4 edges>
gap> DigraphVertexLabels(gr3);
[ (), (1,2,3,4) ]
gap> gr4 := DigraphRemoveVertices(gr, []);
<immutable digraph with 4 vertices, 16 edges>
gap> gr = gr4;
true
gap> gr := Digraph([[110], [], [], [3], [3410], [138],
> [9], [9], [3], [3510]]);
<immutable digraph with 10 vertices, 15 edges>
gap> DigraphSinks(gr);
23 ]
gap> DigraphRemoveVertices(gr, DigraphSinks(gr));
<immutable digraph with 8 vertices, 10 edges>

#  DigraphReverseEdge and DigraphReverseEdges
gap> gr := Digraph([[11]]);
<immutable multidigraph with 1 vertex, 2 edges>
gap> DigraphReverseEdges(gr, [[22]]);
Error, the 1st argument <D> must be a digraph with no multiple edges,
gap> DigraphReverseEdges(gr, [2]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> gr := CompleteDigraph(100);
<immutable complete digraph with 100 vertices>
gap> DigraphReverseEdges(gr, "a");
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> DigraphReverseEdges(gr, Group(()));
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdges' on 2 arguments
gap> DigraphReverseEdges(gr, [00]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> DigraphReverseEdges(gr, [[0]]);
Error, the 2nd argument <e> must be a list of length 2,
gap> DigraphReverseEdges(gr, [[1], [1]]);
Error, the 2nd argument <e> must be a list of length 2,
gap> edges := ShallowCopy(DigraphEdges(gr));;
gap> gr = DigraphReverseEdges(gr, edges);
Error, the 1st argument <D> must be a digraph with no multiple edges,
gap> gr = DigraphReverseEdges(gr, [1 .. DigraphNrEdges(gr)]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> DigraphReverseEdge(gr, 2) = DigraphReverseEdge(gr, [13]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> gr = DigraphReverseEdges(gr, []);
true
gap> gr := CycleDigraph(100);
<immutable cycle digraph with 100 vertices>
gap> edges := ShallowCopy(DigraphEdges(gr));;
gap>  gr = DigraphReverseEdges(gr, edges);
false
gap> gr2 := DigraphReverseEdges(gr, edges);
<immutable digraph with 100 vertices, 100 edges>
gap> gr = gr2;
false
gap> edges2 := ShallowCopy(DigraphEdges(gr2));;
gap> gr = DigraphReverseEdges(gr2, edges2);
true
gap> gr = DigraphReverseEdges(gr, [1 .. DigraphNrEdges(gr)]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> DigraphReverseEdge(gr, 1) = DigraphReverseEdge(gr, [12]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DigraphReverseEdge' on 2 arguments
gap> gr = DigraphReverseEdges(gr, []);
true

#  DigraphFloydWarshall
gap> func := function(mat, i, j, k)
>   if (i = j) or (mat[i][k] <> 0 and mat[k][j] <> 0) then
>     mat[i][j] := 1;
>   fi;
> end;
function( mat, i, j, k ) ... end
gap> gr := Digraph(
> [[12457], [12], [37], [210], [26], [27],
>  [], [34], [110], [139]]);
<immutable digraph with 10 vertices, 22 edges>
gap> rtclosure := DigraphFloydWarshall(gr, func, 01);;
gap> grrt := DigraphByAdjacencyMatrix(rtclosure);
<immutable digraph with 10 vertices, 76 edges>
gap> grrt = DigraphReflexiveTransitiveClosure(gr);
true
gap> func := function(mat, i, j, k)
>   if mat[i][k] <> 0 and mat[k][j] <> 0 then
>     mat[i][j] := 1;
>   fi;
> end;
function( mat, i, j, k ) ... end
gap> gr := Digraph(rec(
> DigraphNrVertices := 10,
> DigraphSource := [12234567101010],
> DigraphRange := [69573484798]));
<immutable digraph with 10 vertices, 11 edges>
gap> tclosure := DigraphFloydWarshall(gr, func, 01);;
gap> grt := DigraphByAdjacencyMatrix(tclosure);
<immutable digraph with 10 vertices, 25 edges>
gap> grt = DigraphTransitiveClosure(gr);
true
gap> func := function(mat, i, j, k)
>   if (i = j) or (mat[i][k] <> 0 and mat[k][j] <> 0) then
>     mat[i][j] := 1;
>   fi;
> end;
function( mat, i, j, k ) ... end
gap> gr := Digraph(
> [[12457], [12], [37], [210], [26], [27],
>  [], [34], [110], [139]]);
<immutable digraph with 10 vertices, 22 edges>
gap> rtclosure := DigraphFloydWarshall(gr, func, 01);;
gap> grrt := DigraphByAdjacencyMatrix(rtclosure);
<immutable digraph with 10 vertices, 76 edges>
gap> grrt = DigraphReflexiveTransitiveClosure(gr);
true
gap> func := function(mat, i, j, k)
>   if mat[i][k] <> 0 and mat[k][j] <> 0 then
>     mat[i][j] := 1;
>   fi;
> end;
function( mat, i, j, k ) ... end
gap> gr := DigraphFromDigraph6String("&I???@?A`?G?GCCS@??");
<immutable digraph with 10 vertices, 11 edges>
gap> tclosure := DigraphFloydWarshall(gr, func, 01);;
gap> grt := DigraphByAdjacencyMatrix(tclosure);
<immutable digraph with 10 vertices, 25 edges>
gap> grt = DigraphTransitiveClosure(gr);
true

#  DigraphDisjointUnion
gap> gr := CycleDigraph(1000);
<immutable cycle digraph with 1000 vertices>
gap> gr2 := CompleteDigraph(100);
<immutable complete digraph with 100 vertices>
gap> DigraphDisjointUnion(gr) = gr;
true
gap> DigraphDisjointUnion([[]]);
Error, the arguments must be digraphs by out-neighbours, or a single non-empty\
 list of digraphs by out-neighbours,
gap> DigraphDisjointUnion([gr], [gr]);
Error, the arguments must be digraphs by out-neighbours, or a single non-empty\
 list of digraphs by out-neighbours,
gap> DigraphDisjointUnion(gr, Group(()));
Error, the arguments must be digraphs by out-neighbours, or a single non-empty\
 list of digraphs by out-neighbours,
gap> DigraphDisjointUnion(gr, gr);
<immutable digraph with 2000 vertices, 2000 edges>
gap> DigraphDisjointUnion(gr, gr2);
<immutable digraph with 1100 vertices, 10900 edges>
gap> gr := CycleDigraph(1000);;
gap> DigraphDisjointUnion(gr2, gr);
<immutable digraph with 1100 vertices, 10900 edges>
gap> gr1 := Digraph([[223], [3], [2]]);
<immutable multidigraph with 3 vertices, 5 edges>
gap> gr2 := Digraph([[12], [1]]);
<immutable digraph with 2 vertices, 3 edges>
gap> gr3 := Digraph(rec(DigraphNrVertices := 2,
> DigraphSource := [112], DigraphRange := [211]));;
gap> gr2 = gr3;
true
gap> u1 := DigraphDisjointUnion(gr1, gr2);
<immutable multidigraph with 5 vertices, 8 edges>
gap> u2 := DigraphDisjointUnion(gr1, gr3);
<immutable multidigraph with 5 vertices, 8 edges>
gap> u1 = u2;
true
gap> D := CycleDigraph(IsMutableDigraph, 2);
<mutable digraph with 2 vertices, 2 edges>
gap> DigraphVertexLabels(D);
12 ]
gap> DigraphDisjointUnion(D, D);
<mutable digraph with 4 vertices, 4 edges>
gap> DigraphVertexLabels(D);
1 .. 4 ]

#  DigraphDisjointUnion: for a list of digraphs
gap> DigraphDisjointUnion([CompleteDigraph(100), CompleteDigraph(100)]);
<immutable digraph with 200 vertices, 19800 edges>
gap> gr := DigraphDisjointUnion(List([2 .. 5], ChainDigraph));
<immutable digraph with 14 vertices, 10 edges>
gap> gr := DigraphAddEdges(gr, [[23], [56], [910]]);
<immutable digraph with 14 vertices, 13 edges>
gap> gr = ChainDigraph(14);
true
gap> n := 10;;
gap> DigraphDisjointUnion(List([1 .. n], EmptyDigraph)) =
> EmptyDigraph(Int(n * (n + 1) / 2));
true
gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;
gap> L := [D1, D2];
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> DigraphDisjointUnion(L) = DigraphFromDigraph6String("&EOG_@CA");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> MakeImmutable(L);; IsMutable(L);
false
gap> DigraphDisjointUnion(L) = DigraphFromDigraph6String("&EOG_@CA");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]

#  DigraphEdgeUnion
gap> gr1 := DigraphFromDigraph6String("&I????@A_?AA???@d??");
<immutable digraph with 10 vertices, 9 edges>
gap> gr2 := DigraphFromDiSparse6String(".H`OS?aEMC?bneOY`l_?QCJ");
<immutable multidigraph with 9 vertices, 20 edges>
gap> DigraphEdgeUnion(gr1) = gr1;
true
gap> DigraphEdgeUnion([[]]);
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> DigraphEdgeUnion([gr1], [gr1]);
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> DigraphEdgeUnion(gr1, Group(()));
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> m1 := DigraphEdgeUnion(gr1, gr2);
<immutable multidigraph with 10 vertices, 29 edges>
gap> m2 := DigraphEdgeUnion(gr2, gr1);
<immutable multidigraph with 10 vertices, 29 edges>
gap> gr1 := Digraph([[2], [], [4], [], [6], []]);
<immutable digraph with 6 vertices, 3 edges>
gap> gr2 := Digraph([[], [3], [], [5], [], [1]]);
<immutable digraph with 6 vertices, 3 edges>
gap> m := DigraphEdgeUnion(gr1, gr2);
<immutable digraph with 6 vertices, 6 edges>
gap> m = CycleDigraph(6);
true
gap> m = DigraphEdgeUnion(gr2, gr1);
true
gap> DigraphEdgeUnion(EmptyDigraph(0), EmptyDigraph(0)) = EmptyDigraph(0);
true
gap> DigraphEdgeUnion(EmptyDigraph(5), EmptyDigraph(3)) = EmptyDigraph(5);
true
gap> gr := DigraphNC([[633106], [4], [51], [546],
> [9], [8], [76], [81081], [], [2]]);;
gap> gr := DigraphEdgeUnion(gr, gr);
<immutable multidigraph with 10 vertices, 40 edges>
gap> OutNeighbours(gr);
[ [ 633106633106 ], [ 44 ], [ 5151 ], 
  [ 546546 ], [ 99 ], [ 88 ], [ 7676 ], 
  [ 8108181081 ], [  ], [ 22 ] ]
gap> gr := DigraphEdgeUnion(ChainDigraph(2), ChainDigraph(3), ChainDigraph(4));
<immutable multidigraph with 4 vertices, 6 edges>
gap> OutNeighbours(gr);
[ [ 222 ], [ 33 ], [ 4 ], [  ] ]

#  DigraphEdgeUnion: for a list of digraphs
gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;
gap> L := [D1, D2];
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> DigraphEdgeUnion(L) = CompleteDigraph(3);
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> MakeImmutable(L);; IsMutable(L);
false
gap> DigraphEdgeUnion(L) = CompleteDigraph(3);
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> D1 := ChainDigraph(IsMutableDigraph, 4);;
gap> SetDigraphVertexLabels(D1, ["some", "nice", "vertex", "labels"]);;
gap> D2 := DigraphReverse(ChainDigraph(5));;
gap> DigraphEdgeUnion(D1, D2);;
gap> DigraphVertexLabels(D1);
1 .. 5 ]

#  DigraphJoin
gap> gr := CompleteDigraph(20);
<immutable complete digraph with 20 vertices>
gap> gr2 := EmptyDigraph(10);
<immutable empty digraph with 10 vertices>
gap> DigraphJoin(gr) = gr;
true
gap> DigraphJoin([[]]);
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> DigraphJoin([gr], [gr]);
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> DigraphJoin([gr, Group(())]);
Error, the arguments must be digraphs by out-neighbours, or a single list of d\
igraphs by out-neighbours,
gap> DigraphJoin(gr, gr2);
<immutable digraph with 30 vertices, 780 edges>
gap> DigraphJoin(gr, EmptyDigraph(0)) = gr;
true
gap> D := CycleDigraph(1000);
<immutable cycle digraph with 1000 vertices>
gap> DigraphJoin(EmptyDigraph(0), D) = D;
true
gap> DigraphNrVertices(DigraphJoin(EmptyDigraph(0), EmptyDigraph(0)));
0
gap> D := EmptyDigraph(5);;
gap> DigraphJoin(D, D) = CompleteBipartiteDigraph(55);
true
gap> gr1 := Digraph([[223], [3], [2]]);
<immutable multidigraph with 3 vertices, 5 edges>
gap> gr2 := Digraph([[12], [1]]);
<immutable digraph with 2 vertices, 3 edges>
gap> gr3 := Digraph(rec(
>   DigraphNrVertices := 2,
>   DigraphSource := [112],
>   DigraphRange := [211]
> ));;
gap> gr2 = gr3;
true
gap> j1 := DigraphJoin(gr1, gr2);
<immutable multidigraph with 5 vertices, 20 edges>
gap> j2 := DigraphJoin(gr1, gr3);
<immutable multidigraph with 5 vertices, 20 edges>
gap> u1 = u2;
true
gap> gr := DigraphJoin(ChainDigraph(2), CycleDigraph(4), EmptyDigraph(0));
<immutable digraph with 6 vertices, 21 edges>
gap> mat := [
> [011111],
> [001111],
> [110100],
> [110010],
> [110001],
> [111000]];;
gap> AdjacencyMatrix(gr) = mat;
true
gap> DigraphJoin(EmptyDigraph(3), EmptyDigraph(2)) =
> CompleteBipartiteDigraph(32);
true

#  DigraphJoin: for a list of digraphs
gap> DigraphJoin(List([1 .. 5], x -> EmptyDigraph(1))) = CompleteDigraph(5);
true
gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;
gap> L := [D1, D2];
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> DigraphJoin(L) = DigraphFromDigraph6String("&EVNfx{y");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> MakeImmutable(L);; IsMutable(L);
false
gap> DigraphJoin(L) = DigraphFromDigraph6String("&EVNfx{y");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]

#  OutNeighboursMutableCopy
gap> gr := Digraph([[3], [10], [6], [3], [10], [], [6], [3], [], [3]]);
<immutable digraph with 10 vertices, 8 edges>
gap> out1 := OutNeighbours(gr);
[ [ 3 ], [ 10 ], [ 6 ], [ 3 ], [ 10 ], [  ], [ 6 ], [ 3 ], [  ], [ 3 ] ]
gap> IsMutable(out1);
false
gap> IsMutable(out1[1]);
false
gap> out2 := OutNeighboursMutableCopy(gr);
[ [ 3 ], [ 10 ], [ 6 ], [ 3 ], [ 10 ], [  ], [ 6 ], [ 3 ], [  ], [ 3 ] ]
gap> IsMutable(out2);
true
gap> IsMutable(out2[1]);
true
gap> out3 := OutNeighborsMutableCopy(gr);
[ [ 3 ], [ 10 ], [ 6 ], [ 3 ], [ 10 ], [  ], [ 6 ], [ 3 ], [  ], [ 3 ] ]
gap> IsMutable(out3);
true
gap> IsMutable(out3[1]);
true

#  InNeighboursMutableCopy
gap> gr := Digraph([[3], [10], [6], [3], [10], [], [6], [3], [], [3]]);
<immutable digraph with 10 vertices, 8 edges>
gap> in1 := InNeighbours(gr);
[ [  ], [  ], [ 14810 ], [  ], [  ], [ 37 ], [  ], [  ], [  ], 
  [ 25 ] ]
gap> IsMutable(in1);
false
gap> IsMutable(in1[1]);
false
gap> in2 := InNeighboursMutableCopy(gr);
[ [  ], [  ], [ 14810 ], [  ], [  ], [ 37 ], [  ], [  ], [  ], 
  [ 25 ] ]
gap> IsMutable(in2);
true
gap> IsMutable(in2[1]);
true
gap> in3 := InNeighborsMutableCopy(gr);
[ [  ], [  ], [ 14810 ], [  ], [  ], [ 37 ], [  ], [  ], [  ], 
  [ 25 ] ]
gap> IsMutable(in3);
true
gap> IsMutable(in3[1]);
true

#  AdjacencyMatrixMutableCopy
gap> gr := CycleDigraph(3);;
gap> adj := AdjacencyMatrixMutableCopy(gr);;
gap> PrintArray(adj);
[ [  0,  1,  0 ],
  [  0,  0,  1 ],
  [  1,  0,  0 ] ]
gap> adj[3][2] := 1;;
gap> PrintArray(adj);
[ [  0,  1,  0 ],
  [  0,  0,  1 ],
  [  1,  1,  0 ] ]

#  BooleanAdjacencyMatrixMutableCopy
gap> gr := Digraph([[3], [23], [3], [24]]);;
gap> adj := BooleanAdjacencyMatrixMutableCopy(gr);;
gap> PrintArray(adj);
[ [  false,  false,   true,  false ],
  [  false,   true,   true,  false ],
  [  false,  false,   true,  false ],
  [  false,   true,  false,   true ] ]
gap> adj[3][1] := true;;
gap> PrintArray(adj);
[ [  false,  false,   true,  false ],
  [  false,   true,   true,  false ],
  [   true,  false,   true,  false ],
  [  false,   true,  false,   true ] ]

#  DigraphRemoveAllMultipleEdges
gap> gr1 := Digraph([[1121], [1]]);
<immutable multidigraph with 2 vertices, 5 edges>
gap> gr2 := DigraphRemoveAllMultipleEdges(gr1);
<immutable digraph with 2 vertices, 3 edges>
gap> OutNeighbours(gr2);
[ [ 12 ], [ 1 ] ]
gap> gr3 := DigraphEdgeUnion(gr1, gr1);
<immutable multidigraph with 2 vertices, 10 edges>
gap> gr4 := DigraphRemoveAllMultipleEdges(gr3);
<immutable digraph with 2 vertices, 3 edges>
gap> gr2 = gr4;
true

#  IsReachable
gap> gr1 := DigraphRemoveEdges(CycleDigraph(100), [[1001], [99100]]);
<immutable digraph with 100 vertices, 98 edges>
gap> IsReachable(gr1, 01);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsReachable' on 3 arguments
gap> IsReachable(gr1, 1011);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> IsReachable(gr1, 1101);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> IsReachable(gr1, 12);
true
gap> gr1 := DigraphRemoveEdges(CycleDigraph(100), [[1001], [99100]]);;
gap> AdjacencyMatrix(gr1);;
gap> IsReachable(gr1, 12);
true
gap> gr1 := DigraphRemoveEdges(CycleDigraph(100), [[1001], [99100]]);;
gap> IsReachable(gr1, 1001);
false
gap> gr1 := DigraphRemoveEdges(CycleDigraph(100), [[1001], [99100]]);;
gap> DigraphConnectedComponents(gr1);;
gap> IsReachable(gr1, 1001);
false
gap> gr1 := CycleDigraph(100);
<immutable cycle digraph with 100 vertices>
gap> IsReachable(gr1, 150);
true
gap> IsReachable(gr1, 11);
true
gap> gr1 := CycleDigraph(100);;
gap> DigraphStronglyConnectedComponents(gr1);;
gap> IsReachable(gr1, 150);
true
gap> IsReachable(gr1, 11);
true
gap> gr1 := Digraph([[2], [1], [3], []]);
<immutable digraph with 4 vertices, 3 edges>
gap> IsReachable(gr1, 12);
true
gap> IsReachable(gr1, 11);
true
gap> IsReachable(gr1, 33);
true
gap> IsReachable(gr1, 13);
false
gap> IsReachable(gr1, 44);
false
gap> gr1 := Digraph([[2], [1], [3], []]);;
gap> DigraphStronglyConnectedComponents(gr1);
rec( comps := [ [ 12 ], [ 3 ], [ 4 ] ], id := [ 1123 ] )
gap> IsReachable(gr1, 12);
true
gap> IsReachable(gr1, 11);
true
gap> IsReachable(gr1, 33);
true
gap> IsReachable(gr1, 13);
false
gap> IsReachable(gr1, 44);
false
gap> gr := DigraphFromSparse6String(":DA_IAMALN");
<immutable symmetric digraph with 5 vertices, 16 edges>
gap> IsReachable(gr, 12);
false
gap> IsReachable(gr, 14);
true
gap> gr := Digraph(
> [[1345], [], [1345], [1345], [1345]]);;
gap> IsTransitiveDigraph(gr);
true
gap> IsReachable(gr, 12);
false
gap> IsReachable(gr, 14);
true

#  DigraphPath
gap> gr := ChainDigraph(10);
<immutable chain digraph with 10 vertices>
gap> DigraphPath(gr, 12);
[ [ 12 ], [ 1 ] ]
gap> DigraphPath(gr, 11);
fail
gap> DigraphPath(gr, 21);
fail
gap> DigraphPath(gr, 38);
[ [ 345678 ], [ 11111 ] ]
gap> DigraphPath(gr, 111);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> DigraphPath(gr, 111);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> DigraphPath(gr, 1111);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,

#  IteratorOfPaths
gap> gr := CompleteDigraph(5);;
gap> iter := IteratorOfPaths(gr, 26);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> iter := IteratorOfPaths(gr, 66);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> iter := IteratorOfPaths(gr, 62);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> iter := IteratorOfPaths(gr, 25);
<iterator>
gap> for a in iter do
>   Print(a, "\n");
> od;
[ [ 21345 ], [ 1234 ] ]
[ [ 2135 ], [ 124 ] ]
[ [ 21435 ], [ 1334 ] ]
[ [ 2145 ], [ 134 ] ]
[ [ 215 ], [ 14 ] ]
[ [ 23145 ], [ 2134 ] ]
[ [ 2315 ], [ 214 ] ]
[ [ 23415 ], [ 2314 ] ]
[ [ 2345 ], [ 234 ] ]
[ [ 235 ], [ 24 ] ]
[ [ 24135 ], [ 3124 ] ]
[ [ 2415 ], [ 314 ] ]
[ [ 24315 ], [ 3314 ] ]
[ [ 2435 ], [ 334 ] ]
[ [ 245 ], [ 34 ] ]
[ [ 25 ], [ 4 ] ]
gap> iter := IteratorOfPaths(gr, 25);;
gap> for a in iter do
>   if not ForAll([1 .. Length(a[1]) - 1], x ->
>       OutNeighboursOfVertex(gr, a[1][x])[a[2][x]] = a[1][x + 1]) then
>     Print("fail\n");
>   fi;
> od;
gap> iter := IteratorOfPaths(gr, 43);
<iterator>
gap> NextIterator(iter);
[ [ 4123 ], [ 112 ] ]
gap> NextIterator(iter);
[ [ 41253 ], [ 1143 ] ]
gap> copy := ShallowCopy(iter);
<iterator>
gap> NextIterator(copy);
[ [ 413 ], [ 12 ] ]
gap> NextIterator(iter);
[ [ 413 ], [ 12 ] ]
gap> gr := [];;
gap> IteratorOfPaths(gr, 11);;
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the digraph d\
efined by the 1st argument <out>,
gap> gr := [[2]];;
gap> IteratorOfPaths(gr, 11);;
Error, the 1st argument <out> must be a list of out-neighbours of a digraph,
gap> gr := [[0]];;
gap> IteratorOfPaths(gr, 11);;
Error, the 1st argument <out> must be a list of out-neighbours of a digraph,
gap> gr := [[1], [3]];;
gap> IteratorOfPaths(gr, 11);;
Error, the 1st argument <out> must be a list of out-neighbours of a digraph,
gap> gr := [[1], [3], [22]];;
gap> iter := IteratorOfPaths(gr, 11);
<iterator>
gap> for a in iter do
>   Print(a, "\n");
> od;
[ [ 11 ], [ 1 ] ]
gap> gr := DigraphFromDigraph6String("+E?_OHCO");
<immutable digraph with 6 vertices, 6 edges>
gap> iter := IteratorOfPaths(gr, 15);
<iterator>
gap> NextIterator(iter);
[ [ 12345 ], [ 1111 ] ]
gap> NextIterator(iter);
[ [ 12645 ], [ 1211 ] ]
gap> IsDoneIterator(iter);
true

#  DigraphLongestDistanceFromVertex
gap> nbs := [[281011], [35], [4], [], [6], [7], [], [9], [5], [6],
> [12], [13], [14], [6], [151]];;
gap> gr := Digraph(nbs);
<immutable digraph with 15 vertices, 18 edges>
gap> DigraphHasLoops(gr);
true
gap> a := DigraphLongestDistanceFromVertex(gr, 1);
6
gap> 2 in nbs[1];
true
gap> b := DigraphLongestDistanceFromVertex(gr, 2);
3
gap> a >= b + 1;
true
gap> DigraphLongestDistanceFromVertex(gr, 4);
0
gap> DigraphLongestDistanceFromVertex(gr, 15);
infinity
gap> DigraphLongestDistanceFromVertex(gr, 16);
Error, the 2nd argument <v> must be a vertex of the 1st argument <D>,

#  DigraphRandomWalk
gap> gr := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> path := DigraphRandomWalk(gr, 1100);;
gap> Length(path[1]);
101
gap> ForAll(path[1], i -> i in [1 .. 5]);
true
gap> Length(path[2]);
100
gap> ForAll(path[2], i -> i in [1 .. 4]);
true
gap> gr := ChainDigraph(5);
<immutable chain digraph with 5 vertices>
gap> DigraphRandomWalk(gr, 2100);
[ [ 2345 ], [ 111 ] ]
gap> DigraphRandomWalk(gr, 22);  
[ [ 234 ], [ 11 ] ]
gap> DigraphRandomWalk(gr, 5100);
[ [ 5 ], [  ] ]
gap> gr := CompleteBipartiteDigraph(108);;
gap> DigraphRandomWalk(gr, 30);           
[ [ 3 ], [  ] ]
gap> DigraphRandomWalk(gr, 195);
Error, the 2nd argument <v> must be a vertex of the 1st argument <D>,
gap> DigraphRandomWalk(gr, 1235);
Error, the 2nd argument <v> must be a vertex of the 1st argument <D>,
gap> DigraphRandomWalk(gr, 3, -1); 
Error, the 3rd argument <t> must be a non-negative int,

#  DigraphLayers
gap> gr := CompleteDigraph(4);
<immutable complete digraph with 4 vertices>
gap> DigraphLayers(gr, 1);
[ [ 1 ], [ 234 ] ]
gap> DigraphLayers(gr, 2);
[ [ 2 ], [ 341 ] ]
gap> DigraphLayers(gr, 3);
[ [ 3 ], [ 412 ] ]
gap> DigraphLayers(gr, 4);
[ [ 4 ], [ 123 ] ]
gap> gr := ChainDigraph(5);;
gap> DigraphLayers(gr, 2);
[ [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]
gap> DigraphLayers(gr, 4);
[ [ 4 ], [ 5 ] ]
gap> gr := Digraph([[25], [3], [4], [5], [6], [7], [8], [1]]);;
gap> DigraphLayers(gr, 1);
[ [ 1 ], [ 25 ], [ 36 ], [ 47 ], [ 8 ] ]
gap> DigraphLayers(gr, 3);
[ [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 1 ], [ 2 ] ]
gap> DigraphLayers(gr, 6);
[ [ 6 ], [ 7 ], [ 8 ], [ 1 ], [ 25 ], [ 3 ], [ 4 ] ]
gap> DigraphLayers(gr, 7);
[ [ 7 ], [ 8 ], [ 1 ], [ 25 ], [ 36 ], [ 4 ] ]
gap> gr := Digraph([[25], [3], [4], [5], [6], [7], [8], [1], [91011],
> [], []]);;
gap> DigraphLayers(gr, 1);
[ [ 1 ], [ 25 ], [ 36 ], [ 47 ], [ 8 ] ]
gap> DigraphLayers(gr, 9);
[ [ 9 ], [ 1011 ] ]
gap> DigraphLayers(gr, 10);
[ [ 10 ] ]
gap> gr := DigraphFromDigraph6String("&GYHPQgWTIIPW");;
gap> DigraphGroup(gr);
Group([ (1,2)(3,4)(5,6)(7,8), (1,3,2,4)(5,7,6,8), (1,5)(2,6)(3,8)(4,7) ])
gap> DigraphOrbitReps(gr);
1 ]
gap> DigraphLayers(gr, 1);
[ [ 1 ], [ 235 ], [ 4678 ] ]
gap> DigraphLayers(gr, 2);
[ [ 2 ], [ 146 ], [ 3587 ] ]
gap> DigraphLayers(gr, 3);
[ [ 3 ], [ 427 ], [ 1865 ] ]
gap> DigraphLayers(gr, 4);
[ [ 4 ], [ 318 ], [ 2756 ] ]
gap> DigraphLayers(gr, 10);
Error, the 2nd argument <v> must be a vertex of the 1st argument <D>,
gap> DigraphShortestDistance(gr, [256], [37]);
1
gap> DigraphShortestDistance(gr, [2], DigraphLayers(gr, 2)[3]);
2
gap> DigraphShortestDistance(gr, [23], [34]);
0
gap> gr := CompleteDigraph(64);
<immutable complete digraph with 64 vertices>
gap> DigraphShortestDistance(gr, [1 .. 10], [20 .. 23]);
1
gap> DigraphShortestDistance(gr, [113], [20 .. 23]);
1
gap> DigraphShortestDistance(gr, [113], [3841]);
1
gap> gr := ChainDigraph(72);
<immutable chain digraph with 72 vertices>
gap> DigraphShortestDistance(gr, [1 .. 10], [20 .. 23]);
10
gap> DigraphShortestDistance(gr, [113], [20 .. 23]);
7
gap> DigraphShortestDistance(gr, [113], [3841]);
25
gap> gr := DigraphFromDigraph6String("+H^_HRR\P_FWEsio");
<immutable digraph with 9 vertices, 32 edges>
gap> DigraphShortestDistance(last, [12], [7]);
2
gap> DigraphShortestDistance(gr, [1], DigraphLayers(gr, 1)[3]);
2
gap> DigraphShortestDistance(gr, [12], DigraphLayers(gr, 1)[3]);
0
gap> DigraphShortestDistance(gr, [13], DigraphLayers(gr, 1)[3]);
0
gap> DigraphShortestDistance(gr, [16], DigraphLayers(gr, 1)[3]);
1

#  Issue #12
gap> gr := DigraphFromSparse6String(
> ":]n?AL`CB_EDbFE`IGaGHdJIeKGcLK_@MhDCiFLaBJmHFmKJ");
<immutable symmetric digraph with 30 vertices, 90 edges>
gap> G1 := DigraphGroup(gr);;
gap> IsPermGroup(G1) and Length(GeneratorsOfGroup(G1)) = 5;
true
gap> Size(G1);
1440
gap> DigraphShortestDistance(gr, 116);
1

#  DigraphShortestDistance: two inputs
gap> gr := Digraph([[2], [3], [14], [13], [5]]);
<immutable digraph with 5 vertices, 7 edges>
gap> DigraphShortestDistance(gr, 13);
2
gap> DigraphShortestDistance(gr, [33]);
0
gap> DigraphShortestDistance(gr, 52);
fail
gap> DigraphShortestDistances(gr);;
gap> DigraphShortestDistance(gr, [34]);
1

#  DigraphShortestDistance: bad input
gap> DigraphShortestDistance(gr, 174);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> DigraphShortestDistance(gr, [174]);
Error, the 2nd argument <list> must consist of vertices of the 1st argument <D\
>,
gap> DigraphShortestDistance(gr, [1713]);
Error, the 2nd argument <list> must be a list of length 2,

#  DigraphDistancesSet
gap> gr := ChainDigraph(10);
<immutable chain digraph with 10 vertices>
gap> DigraphDistanceSet(gr, 52);
7 ]
gap> gr := DigraphSymmetricClosure(ChainDigraph(10));
<immutable symmetric digraph with 10 vertices, 18 edges>
gap> DigraphDistanceSet(gr, 52);
37 ]
gap> gr := ChainDigraph(10);;
gap> DigraphDistanceSet(gr, 201);
Error, the 2nd argument <vertex> must be a vertex of the digraph,
gap> DigraphDistanceSet(gr, 20, [1]);
Error, the 2nd argument <vertex> must be a vertex of the digraph,
gap> DigraphDistanceSet(gr, 10, ["string", 1]);
Error, the 3rd argument <distances> must be a list of non-negative integers,
gap> gr := DigraphFromDigraph6String("&GYHPQgWTIIPW");;
gap> DigraphDistanceSet(gr, 1, [37]);
[  ]
gap> DigraphDistanceSet(gr, 1, [1]);
235 ]
gap> DigraphDistanceSet(gr, 1, [12]);
2354678 ]
gap> DigraphDistanceSet(gr, 22);
3578 ]
gap> DigraphDistanceSet(gr, 2, -1);
Error, the 3rd argument <distance> must be a non-negative integer,

#  IsSubdigraph: Issue #46
gap> gr1 := Digraph([[2], []]);;
gap> gr2 := Digraph([[22], []]);;
gap> IsSubdigraph(gr1, gr2);
false
gap> IsSubdigraph(gr2, gr1);
true
gap> gr1 = gr2;
false

#  IsSubdigraph: for two digraphs, 1
gap> gr1 := CompleteDigraph(3);;
gap> gr2 := CompleteDigraph(4);;
gap> IsSubdigraph(gr1, gr2) or IsSubdigraph(gr1, gr2);
false
gap> gr3 := CycleDigraph(3);;
gap> IsSubdigraph(gr3, gr1);
false
gap> IsSubdigraph(gr1, gr3);
true
gap> gr4 := Digraph([[11], [22], [33]]);;
gap> IsSubdigraph(gr1, gr4) or IsSubdigraph(gr4, gr1);
false
gap> gr1 := DigraphEdgeUnion(CompleteDigraph(3), CompleteDigraph(3));
<immutable multidigraph with 3 vertices, 12 edges>
gap> gr2 := DigraphEdgeUnion(CycleDigraph(3), CycleDigraph(3));
<immutable multidigraph with 3 vertices, 6 edges>
gap> IsSubdigraph(gr1, gr2);
true
gap> IsSubdigraph(gr2, gr1);
false
gap> gr3 := Digraph([[223], [3], []]);
<immutable multidigraph with 3 vertices, 4 edges>
gap> gr4 := Digraph([[233], [3], []]);
<immutable multidigraph with 3 vertices, 4 edges>
gap> IsSubdigraph(gr3, gr4) or IsSubdigraph(gr4, gr3);
false
gap> gr1 := Digraph([[11], []]);
<immutable multidigraph with 2 vertices, 2 edges>
gap> gr2 := Digraph([[], [22]]);
<immutable multidigraph with 2 vertices, 2 edges>
gap> IsSubdigraph(gr1, gr2) or IsSubdigraph(gr2, gr1);
false

#  IsUndirectedSpanningForest
gap> gr1 := CompleteDigraph(10);
<immutable complete digraph with 10 vertices>
gap> gr2 := EmptyDigraph(9);
<immutable empty digraph with 9 vertices>
gap> IsUndirectedSpanningForest(gr1, gr2);
false
gap> gr2 := DigraphAddEdge(EmptyDigraph(10), [12]);
<immutable digraph with 10 vertices, 1 edge>
gap> IsUndirectedSpanningForest(gr1, gr2);
false
gap> gr2 := DigraphAddEdge(gr2, [21]);
<immutable digraph with 10 vertices, 2 edges>
gap> IsUndirectedSpanningForest(gr1, gr2);
false
gap> IsUndirectedSpanningForest(gr1, DigraphFromSparse6String(":I`ESyTl^F"));
true
gap> gr := DigraphFromDigraph6String("&I?PIMAQc@A?W?ADPP?");
<immutable digraph with 10 vertices, 23 edges>
gap> IsUndirectedSpanningForest(gr, DigraphByEdges([[27], [72]], 10));
true

#  IsUndirectedSpanningTree
gap> IsUndirectedSpanningTree(EmptyDigraph(1), EmptyDigraph(1));
true
gap> IsUndirectedSpanningTree(EmptyDigraph(2), EmptyDigraph(2));
false
gap> gr := DigraphFromDigraph6String("&I?PIMAQc@A?W?ADPP?");
<immutable digraph with 10 vertices, 23 edges>
gap> IsUndirectedSpanningTree(gr, EmptyDigraph(10));
false
gap> gr := DigraphFromGraph6String("INB`cZoQ_");
<immutable symmetric digraph with 10 vertices, 38 edges>
gap> IsUndirectedSpanningTree(gr, gr);
false
gap> gr1 := DigraphEdgeUnion(CycleDigraph(5), DigraphReverse(CycleDigraph(5)));
<immutable digraph with 5 vertices, 10 edges>
gap> gr2 := DigraphEdgeUnion(ChainDigraph(5), DigraphReverse(ChainDigraph(5)));
<immutable digraph with 5 vertices, 8 edges>
gap> IsUndirectedSpanningTree(gr1, gr2);
true
gap> IsUndirectedSpanningTree(gr2, gr2);
true

#  PartialOrderDigraphMeetOfVertices
gap> gr := CycleDigraph(5);
<immutable cycle digraph with 5 vertices>
gap> PartialOrderDigraphJoinOfVertices(gr, 14);
Error, the 1st argument <D> must satisfy IsPartialOrderDigraph,
gap> D := DigraphReflexiveTransitiveClosure(ChainDigraph(4));
<immutable preorder digraph with 4 vertices, 10 edges>
gap> IsJoinSemilatticeDigraph(D);
true
gap> PartialOrderDigraphJoinOfVertices(D, 23);
3
gap> IsMeetSemilatticeDigraph(D);
true
gap> PartialOrderDigraphMeetOfVertices(D, 23);
2

#Join semilattice on 9 vertices
gap> gr := DigraphFromDiSparse6String(".HiR@AeNcC?oD?G`oAGXIoAGXAe_COqDK^F");
<immutable digraph with 9 vertices, 36 edges>
gap> PartialOrderDigraphMeetOfVertices(gr, 23);
1
gap> PartialOrderDigraphJoinOfVertices(gr, 23);
4
gap> PartialOrderDigraphJoinOfVertices(gr, 39);
5
gap> PartialOrderDigraphMeetOfVertices(gr, 39);
fail
gap> gr := DigraphReverse(gr);
<immutable digraph with 9 vertices, 36 edges>
gap> PartialOrderDigraphMeetOfVertices(gr, 23);
4
gap> PartialOrderDigraphJoinOfVertices(gr, 23);
1
gap> PartialOrderDigraphMeetOfVertices(gr, 39);
5

# Testing invalid input
gap> gr := Digraph([[123], [123], [123]]);
<immutable digraph with 3 vertices, 9 edges>
gap> PartialOrderDigraphMeetOfVertices(gr, 23);
Error, the 1st argument <D> must satisfy IsPartialOrderDigraph,
gap> PartialOrderDigraphJoinOfVertices(gr, 23);
Error, the 1st argument <D> must satisfy IsPartialOrderDigraph,
gap> gr1 := Digraph([[1], [2], [123], [124]]);
<immutable digraph with 4 vertices, 8 edges>
gap> gr2 := DigraphReverse(gr1);
<immutable digraph with 4 vertices, 8 edges>

# Meet does not exist
gap> PartialOrderDigraphMeetOfVertices(gr1, 34);
fail
gap> PartialOrderDigraphMeetOfVertices(gr2, 34);
fail

# Join does not exist
gap> PartialOrderDigraphJoinOfVertices(gr2, 34);
fail
gap> PartialOrderDigraphJoinOfVertices(gr1, 34);
fail

#  DigraphClosure
gap> gr := Digraph([[45679], [73], [267910],
> [56719], [1467], [71345],
> [14923568], [7], [147310], [93]]);;
gap> DigraphNrEdges(gr);
42
gap> DigraphNrEdges(DigraphClosure(gr, 10));
54
gap> DigraphNrEdges(DigraphClosure(gr, 9));
90
gap> DigraphNrEdges(DigraphClosure(gr, 11));
42
gap> gr := Digraph([[1], [2], [3]]);;
gap> DigraphClosure(gr, 2);
Error, the 1st argument <D> must be a symmetric digraph with no loops, and no \
multiple edges,
gap> gr := Digraph([[2], [3], [1]]);;
gap> DigraphClosure(gr, 2);
Error, the 1st argument <D> must be a symmetric digraph with no loops, and no \
multiple edges,

#  IsMatching
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[14], [23]];;
gap>  IsMatching(gr, edges);
false
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[12], [43]];;
gap>  IsMatching(gr, edges);
false
gap>  edges := [[12], [34]];;
gap>  IsMatching(gr, edges);
true
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[14], [41], [23]];;
gap>  IsMatching(gr, edges);
false
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[11], [23]];;
gap>  IsMatching(gr, edges);
false
gap>  gr := Digraph([[12], [3], [4], []]);;
gap>  edges := [[11], [23]];;
gap>  IsMatching(gr, edges);
true
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[12], [34]];;
gap>  IsMatching(gr, edges);
true
gap>  gr := Digraph([[2], [3], [4], []]);;
gap>  edges := [[12], [23]];;
gap>  IsMatching(gr, edges);
false
gap>  gr := CompleteDigraph(999);;
gap>  edges := [[12], [45], [67]];;
gap>  IsMatching(gr, edges);
true
gap> gr := CompleteDigraph(999);;
gap>  edges := [];;
gap>  for i in [1 .. 499] do Append(edges, [[2 * i, 2 * i + 1]]); od;;
gap>  IsMatching(gr, edges);
true
gap> gr := CompleteDigraph(999);;
gap> edges := [[12], [34], [45], [67]];;
gap>  IsMatching(gr, edges);
false

#  IsPerfectMatching
gap> gr := Digraph([[2], [3], [4], [5], [1]]);
<immutable digraph with 5 vertices, 5 edges>
gap> IsPerfectMatching(gr, [[13]]);
false
gap> edges := [[12], [45]];;
gap> IsMatching(gr, edges);
true
gap> IsPerfectMatching(gr, edges);
false
gap> gr := CompleteDigraph(500);
<immutable complete digraph with 500 vertices>
gap> edges := [];;
gap> for i in [0 .. 249] do
>   Append(edges, [[2 * i + 12 * i + 2]]);
> od;;
gap> IsPerfectMatching(gr, edges);
true
gap> gr := Digraph([[2], [34], [], [5], [16], [1]]);
<immutable digraph with 6 vertices, 7 edges>
gap> edges := [[16], [23], [54]];;
gap> IsMatching(gr, edges);
false
gap> edges := [[61], [23], [45]];;
gap> IsPerfectMatching(gr, edges);
true
gap> gr := Digraph([[2], [3], [43], [5], [1]]);
<immutable digraph with 5 vertices, 6 edges>
gap> edges := [[12], [45], [33]];;
gap> IsPerfectMatching(gr, edges);
true

#  IsMaximalMatching
gap> gr := Digraph([[2], [3], [4], [5], [1]]);
<immutable digraph with 5 vertices, 5 edges>
gap> edges := [[12], [43]];;
gap> IsMatching(gr, edges);
false
gap> edges := [[12], [34]];;
gap> IsMaximalMatching(gr, edges);
true
gap> gr := Digraph([[2], [3], [4], [5], [15]]);
<immutable digraph with 5 vertices, 6 edges>
gap> edges := [[12], [34]];;
gap> IsMaximalMatching(gr, edges);
false
gap> gr := CompleteDigraph(5);;
gap> edges := [[12], [13]];;
gap> IsMaximalMatching(gr, edges);
false
gap> gr := Digraph([[2], [3], [4], [1]]);;
gap> edges := [[21], [43]];;
gap> IsMatching(gr, edges);
false
gap> edges := [[12], [34]];;
gap> IsMaximalMatching(gr, edges);
true
gap> gr := Digraph([[2], [3], [1], [5], [6], [4]]);;
gap> edges := [[12], [45]];;
gap> IsMaximalMatching(gr, edges);
true
gap> gr := Digraph([[12], [3], [4], [1]]);;
gap> edges := [[11], [23]];
[ [ 11 ], [ 23 ] ]
gap> IsMaximalMatching(gr, edges);
true

# IsMaximumMatching
gap> D := Digraph([[12], [12], [234], [35], [1]]);
<immutable digraph with 5 vertices, 10 edges>
gap> IsMaximumMatching(D, [[12], [33], [45]]);
false
gap> IsMaximumMatching(D, [[11], [22], [33], [45]]);
true
gap> IsMaximumMatching(D, [[11], [12], [22], [33], [45]]);
false

# DigraphShortestPath
gap> gr := Digraph([[1], [34], [56], [423], [45], [1]]);;
gap> DigraphShortestPath(gr, 16);
fail
gap> DigraphShortestPath(gr, 25);
[ [ 235 ], [ 11 ] ]
gap> DigraphShortestPath(gr, 33);
[ [ 3543 ], [ 113 ] ]
gap> DigraphShortestPath(gr, 66);
fail
gap> DigraphShortestPath(gr, 55);
[ [ 55 ], [ 2 ] ]
gap> gr := Digraph([[]]);;
gap> DigraphShortestPath(gr, 11);
fail
gap> gr := Digraph([[], []]);;
gap> DigraphShortestPath(gr, 21);
fail
gap> gr := Digraph([[2], [1], [3]]);;
gap> DigraphShortestPath(gr, 12);
[ [ 12 ], [ 1 ] ]
gap> gr := CayleyDigraph(SymmetricGroup(7));;
gap> DigraphShortestPath(gr, 125014);
[ [ 1287815810291875188127543498352236424508438868
      7881634250532493273414650125014 ], 
  [ 21221221221212221221 ] ]

# IsReachableFrom
gap> D := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> VerticesReachableFrom(D, 1);
12345 ]
gap> VerticesReachableFrom(D, 3);
12345 ]
gap> D := EmptyDigraph(5);
<immutable empty digraph with 5 vertices>
gap> VerticesReachableFrom(D, 1);
[  ]
gap> VerticesReachableFrom(D, 3);
[  ]
gap> VerticesReachableFrom(D, 6);
Error, the 2nd argument (root) is not a vertex of the 1st argument (a digraph)
gap> D := CycleDigraph(4);
<immutable cycle digraph with 4 vertices>
gap> VerticesReachableFrom(D, 1);
1234 ]
gap> VerticesReachableFrom(D, 3);
1234 ]
gap> D := ChainDigraph(5);
<immutable chain digraph with 5 vertices>
gap> VerticesReachableFrom(D, 1);
2345 ]
gap> VerticesReachableFrom(D, 3);
45 ]
gap> VerticesReachableFrom(D, 5);
[  ]
gap> D := Digraph([[235], [16], [467], [78], [4], [], [86], []]);
<immutable digraph with 8 vertices, 13 edges>
gap> VerticesReachableFrom(D, 1);
12345678 ]
gap> VerticesReachableFrom(D, 2);
12345678 ]
gap> VerticesReachableFrom(D, 3);
4678 ]
gap> VerticesReachableFrom(D, 4);
678 ]
gap> VerticesReachableFrom(D, 5);
4678 ]
gap> VerticesReachableFrom(D, 6);
[  ]
gap> VerticesReachableFrom(D, 7);
68 ]
gap> VerticesReachableFrom(D, 8);
[  ]
gap> D := Digraph([[123], [4], [15], [], [2]]);
<immutable digraph with 5 vertices, 7 edges>
gap> VerticesReachableFrom(D, 1);
12345 ]
gap> VerticesReachableFrom(D, 2);
4 ]
gap> VerticesReachableFrom(D, 3);
12345 ]
gap> VerticesReachableFrom(D, 4);
[  ]
gap> VerticesReachableFrom(D, 5);
24 ]
gap> D := Digraph(IsMutableDigraph, [[123], [4], [15], [], [2]]);
<mutable digraph with 5 vertices, 7 edges>
gap> VerticesReachableFrom(D, 1);
12345 ]
gap> VerticesReachableFrom(D, 2);
4 ]
gap> VerticesReachableFrom(D, 3);
12345 ]
gap> VerticesReachableFrom(D, 4);
[  ]
gap> VerticesReachableFrom(D, 5);
24 ]
gap> D;
<mutable digraph with 5 vertices, 7 edges>

# DisjointUnion etc
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphDisjointUnion(D, D, D, D, D, D, D, D, D, D);
<mutable digraph with 30 vertices, 30 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphDisjointUnion(D, CycleDigraph(3), CycleDigraph(3),
> CycleDigraph(3));
<mutable digraph with 12 vertices, 12 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphJoin(D, D, D);
<mutable digraph with 9 vertices, 63 edges>
gap> D := CycleDigraph(IsMutableDigraph, 3);
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphEdgeUnion(D, D, D);
<mutable multidigraph with 3 vertices, 9 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphJoin(D, CycleDigraph(3), CycleDigraph(3),
> CycleDigraph(3));
<mutable digraph with 12 vertices, 120 edges>
gap> D := CycleDigraph(3);
<immutable cycle digraph with 3 vertices>
gap> DigraphJoin(D, D, D);
<immutable digraph with 9 vertices, 63 edges>
gap> DigraphJoin(D, CycleDigraph(3), CycleDigraph(3),
> CycleDigraph(3));
<immutable digraph with 12 vertices, 120 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphEdgeUnion(D, CycleDigraph(3), CycleDigraph(3),
> CycleDigraph(3));
<mutable multidigraph with 3 vertices, 12 edges>
gap> DD := CycleDigraph(3);
<immutable cycle digraph with 3 vertices>
gap> DD := DigraphEdgeUnion(D, CycleDigraph(3), CycleDigraph(3),
> CycleDigraph(3));
<mutable multidigraph with 3 vertices, 21 edges>
gap> D = DD;
true
gap> D := Digraph(IsMutableDigraph, [[23], [13], [12]]);
<mutable digraph with 3 vertices, 6 edges>
gap> DigraphReverse(D) = Digraph(IsMutableDigraph, [[23], [13], [12]]);
true
gap> DigraphReverseEdge(D, 12);
<mutable multidigraph with 3 vertices, 6 edges>
gap> DigraphReverseEdge(D, 11);
Error, the 1st argument <D> must be a digraph with no multiple edges,
gap> DigraphAddEdge(D, 11);
<mutable multidigraph with 3 vertices, 7 edges>
gap> DigraphReverseEdge(D, 11);
Error, the 1st argument <D> must be a digraph with no multiple edges,
gap> D := Digraph(IsMutableDigraph, [[23], [13], [12]]);
<mutable digraph with 3 vertices, 6 edges>
gap> DigraphAddEdge(D, 11);
<mutable digraph with 3 vertices, 7 edges>
gap> DigraphReverseEdge(D, 11);
<mutable digraph with 3 vertices, 7 edges>
gap> DigraphReverseEdge(D, 14);
Error, there is no edge from 1 to 
4 in the digraph <D> that is the 1st argument,
gap> D := MakeImmutable(D);
<immutable digraph with 3 vertices, 7 edges>
gap> D := DigraphReverseEdge(D, 12);
<immutable multidigraph with 3 vertices, 7 edges>
gap> D := CycleDigraph(3);
<immutable cycle digraph with 3 vertices>
gap> DigraphReverseEdge(D, [12]);
<immutable digraph with 3 vertices, 3 edges>
gap> D := DigraphMutableCopy(CompleteDigraph(10));
<mutable digraph with 10 vertices, 90 edges>
gap> DD := InducedSubdigraph(D, [1246]);
<mutable digraph with 4 vertices, 12 edges>
gap> D;
<mutable digraph with 4 vertices, 12 edges>
gap> D := DigraphMutableCopy(CompleteDigraph(10));
<mutable digraph with 10 vertices, 90 edges>
gap> DD := QuotientDigraph(D, [[123], [456], [789], [10]]);
<mutable digraph with 4 vertices, 15 edges>
gap> InNeighboursOfVertexNC(DD, 1);
1234 ]
gap> MakeImmutable(DD);
<immutable digraph with 4 vertices, 15 edges>
gap> InNeighbours(DD);;
gap> InNeighboursOfVertexNC(DD, 1);
1234 ]
gap> InDegreeOfVertexNC(DD, 1);
4
gap> DigraphShortestPath(DD, 15);
Error, the 2nd and 3rd arguments <u> and <v> must be vertices of the 1st argum\
ent <D>,
gap> IsTransitiveDigraph(DD);
false
gap> DD := DigraphTransitiveClosure(DigraphRemoveAllMultipleEdges(DD));
<immutable transitive digraph with 4 vertices, 16 edges>
gap> IsTransitiveDigraph(DD);
true
gap> DigraphShortestPath(DD, 12);
[ [ 12 ], [ 2 ] ]
gap> D := ChainDigraph(4);
<immutable chain digraph with 4 vertices>
gap> D := DigraphTransitiveClosure(D);
<immutable transitive digraph with 4 vertices, 6 edges>
gap> DigraphShortestPath(D, 21);
fail
gap> D := DigraphDisjointUnion(CycleDigraph(3), CycleDigraph(3));
<immutable digraph with 6 vertices, 6 edges>
gap> DigraphConnectedComponents(D);
rec( comps := [ [ 123 ], [ 456 ] ], id := [ 111222 ] )
gap> DigraphShortestPath(D, 14);
fail
gap> D := Digraph([[1]]);
<immutable digraph with 1 vertex, 1 edge>
gap> PartialOrderDigraphMeetOfVertices(D, 12);
Error, the 3rd argument <j> must be a vertex of the 1st argument <D>,
gap> PartialOrderDigraphMeetOfVertices(D, 21);
Error, the 2nd argument <i> must be a vertex of the 1st argument <D>,
gap> PartialOrderDigraphJoinOfVertices(D, 12);
Error, the 3rd argument <j> must be a vertex of the 1st argument <D>,
gap> PartialOrderDigraphJoinOfVertices(D, 21);
Error, the 2nd argument <i> must be a vertex of the 1st argument <D>,

# DigraphCartesianProduct
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphCartesianProduct(D, D, D);
<mutable digraph with 27 vertices, 81 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphCartesianProduct(
> D, CycleDigraph(3), CycleDigraph(3), CycleDigraph(3));
<mutable digraph with 81 vertices, 324 edges>
gap> D := DigraphCartesianProduct(ChainDigraph(3), CycleDigraph(3));
<immutable digraph with 9 vertices, 15 edges>
gap> IsIsomorphicDigraph(D,
> Digraph([[24], [35], [6], [57], [68], [9], [81], [92], [3]]));
true
gap> D := DigraphCartesianProduct(ChainDigraph(3), CycleDigraph(3),
> Digraph([[2], [2]]));
<immutable digraph with 18 vertices, 48 edges>
gap> HasDigraphCartesianProductProjections(D);
true
gap> Length(DigraphCartesianProductProjections(D));
3
gap> G := DigraphFromDigraph6String(
> "&QSC?IA?@@?A__@OO?GG_OCOGAG?@?E_?BO?@G??s??Y??H?CE?AB?@@");;
gap> IsIsomorphicDigraph(D, G);
true
gap> D := RandomDigraph(100);; IsIsomorphicDigraph(D, 
> DigraphCartesianProduct(D, Digraph([[]])));
true
gap> DigraphCartesianProduct(Digraph([[1]]), Digraph([[1]]));
<immutable multidigraph with 1 vertex, 2 edges>

#  DigraphCartesianProduct: for a list of digraphs
gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;
gap> L := [D1, D2];
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> DigraphCartesianProduct(L) = DigraphFromDigraph6String("&HO`A_KOP@_COP@_");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> MakeImmutable(L);; IsMutable(L);
false
gap> DigraphCartesianProduct(L) = DigraphFromDigraph6String("&HO`A_KOP@_COP@_");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]

# DigraphDirectProduct
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphDirectProduct(D, D, D);
<mutable digraph with 27 vertices, 27 edges>
gap> D := DigraphMutableCopy(CycleDigraph(3));
<mutable digraph with 3 vertices, 3 edges>
gap> DigraphDirectProduct(D, CycleDigraph(3), CycleDigraph(3), CycleDigraph(3));
<mutable digraph with 81 vertices, 81 edges>
gap> D := DigraphDirectProduct(ChainDigraph(3), CycleDigraph(3));
<immutable digraph with 9 vertices, 6 edges>
gap> IsIsomorphicDigraph(D,
> Digraph([[5], [6], [], [8], [9], [], [2], [3], []]));
true
gap> D := DigraphDirectProduct(ChainDigraph(3), CycleDigraph(3),
> Digraph([[2], [2]]));
<immutable digraph with 18 vertices, 12 edges>
gap> HasDigraphDirectProductProjections(D);
true
gap> Length(DigraphDirectProductProjections(D));
3
gap> G := DigraphFromDigraph6String(
> "&Q??O??G?????A??@????A??@??????O??G?????A??@????A??@????");;
gap> IsIsomorphicDigraph(D, G);
true
gap> D := RandomDigraph(100);; IsIsomorphicDigraph(D,
> DigraphDirectProduct(D, Digraph([[1]])));
true

#  DigraphDirectProduct: for a list of digraphs
gap> D1 := CycleDigraph(3);; D2 := DigraphReverse(D1);;
gap> L := [D1, D2];
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> DigraphDirectProduct(L) = DigraphFromDiSparse6String(".HeESITfeogP");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]
gap> MakeImmutable(L);; IsMutable(L);
false
gap> DigraphDirectProduct(L) = DigraphFromDiSparse6String(".HeESITfeogP");
true
gap> L;
[ <immutable cycle digraph with 3 vertices>, 
  <immutable digraph with 3 vertices, 3 edges> ]

# Issue 213
gap> D := Digraph(IsMutableDigraph, [[3468], [13467810], 
> [126789], [357], [123689], [26810], 
> [2710], [15810], [1267810], [1268910]]);
<mutable digraph with 10 vertices, 49 edges>
gap> InducedSubdigraph(D, [45]);
<mutable digraph with 2 vertices, 1 edge>
gap> DigraphVertexLabels(D);
45 ]

# Issue 215
gap> D := Digraph([[678], [8], [8], [8], [8], [178], [168],
>                  [3217654]]);;
gap> C := DigraphRemoveVertex(DigraphMutableCopy(D), 5);;
gap> DigraphEdgeLabels(C);
[ [ 111 ], [ 1 ], [ 1 ], [ 1 ], [ 111 ], [ 111 ], 
  [ 111111 ] ]
gap> OutNeighbours(C);
[ [ 567 ], [ 7 ], [ 7 ], [ 7 ], [ 167 ], [ 157 ], 
  [ 321654 ] ]

# DigraphDijkstra - when there is one path to target
gap> mat := [[011], [001], [000]];
[ [ 011 ], [ 001 ], [ 000 ] ]
gap> gr := DigraphByAdjacencyMatrix(mat);
<immutable digraph with 3 vertices, 3 edges>
gap> DigraphShortestDistance(gr, 23);
1
gap> DigraphDijkstra(gr, 23);
[ [ infinity, 01 ], [ -1, -12 ] ]
gap> DigraphDijkstra(gr, 13);
[ [ 011 ], [ -111 ] ]
gap> DigraphDijkstra(gr, 12);
[ [ 011 ], [ -111 ] ]
gap> DigraphShortestDistance(gr, 13);
1
gap> DigraphShortestDistance(gr, 12);
1
gap> mat := [[011], [000], [000]];
[ [ 011 ], [ 000 ], [ 000 ] ]
gap> gr := DigraphByAdjacencyMatrix(mat);
<immutable digraph with 3 vertices, 2 edges>
gap> DigraphShortestDistance(gr, 23);
fail
gap> DigraphDijkstra(gr, 23);
[ [ infinity, 0, infinity ], [ -1, -1, -1 ] ]
gap> mat := [[0111], [0011], [0100], [1000]];
[ [ 0111 ], [ 0011 ], [ 0100 ], [ 1000 ] ]
gap> gr := DigraphByAdjacencyMatrix(mat);
<immutable digraph with 4 vertices, 7 edges>
gap> DigraphDijkstra(gr, 14);
[ [ 0111 ], [ -1111 ] ]
gap> mat := [[0111], [0011], [0100], [1000]];
[ [ 0111 ], [ 0011 ], [ 0100 ], [ 1000 ] ]
gap> gr := DigraphByAdjacencyMatrix(mat);
<immutable digraph with 4 vertices, 7 edges>
gap> DigraphDijkstra(gr, 12);
[ [ 0111 ], [ -1111 ] ]
gap> DigraphDijkstra(gr, 13);
[ [ 0111 ], [ -1111 ] ]

# ModularProduct
gap> ModularProduct(NullDigraph(0), CompleteDigraph(10));
<immutable empty digraph with 0 vertices>
gap> ModularProduct(PetersenGraph(), CompleteDigraph(10));
<immutable digraph with 100 vertices, 2800 edges>
gap> ModularProduct(NullDigraph(10), CompleteDigraph(10));
<immutable digraph with 100 vertices, 100 edges>
gap> ModularProduct(Digraph([[1], [12]]), Digraph([[], [2]]));
<immutable digraph with 4 vertices, 4 edges>
gap> OutNeighbours(last);
[ [ 4 ], [ 23 ], [  ], [ 4 ] ]
gap> ModularProduct(PetersenGraph(), DigraphSymmetricClosure(CycleDigraph(5)));
<immutable digraph with 50 vertices, 950 edges>
gap> OutNeighbours(last);
[ [ 710222527301131418193334383943444849 ]
    , [ 682123262821415192034353940444549
      50 ], 
  [ 79222427293111516203135364041454650 ],
  [ 810232528304111216173132363741424647 ]
    , [ 692124262951213171832333738424347
      48 ], 
  [ 25121532356181923242829383943444849 ],
  [ 13111331337192024252930394044454950 ],
  [ 24121432348162021252630364041454650 ],
  [ 35131533359161721222627363741424647 ],
  [ 141114313410171822232728373842434748 ]
    , [ 710172037403411232428293334434448
      49 ], [ 681618363845122425293034354445
      4950 ], 
  [ 7917193739151321252630313541454650 ], 
  [ 81018203840121421222627313241424647 ],
  [ 6916193639231522232728323342434748 ], 
  [ 1215222542453489162829333438394849 ], 
  [ 11132123414345910172930343539404950 ],
  [ 12142224424415610182630313536404650 ],
  [ 1315232543451267192627313236374647 ], 
  [ 1114212441442378202728323337384748 ], 
  [ 2517204750891314212829333438394344 ], 
  [ 13161846489101415222930343539404445 ],
  [ 24171947496101115232630313536404145 ],
  [ 3518204850671112242627313236374142 ], 
  [ 1416194649781213252728323337384243 ], 
  [ 2537404245891314181923242633344849 ], 
  [ 13363841439101415192024252734354950 ],
  [ 24373942446101115162021252831354650 ],
  [ 3538404345671112161721222931324647 ], 
  [ 1436394144781213171822233032334748 ], 
  [ 71042454750341314181923242829313839 ],
  [ 6841434648451415192024252930323940 ], 
  [ 7942444749151115162021252630333640 ], 
  [ 81043454850121112161721222627343637 ],
  [ 6941444649231213171822232728353738 ], 
  [ 1215273047503489181923243334364344 ], 
  [ 11132628464845910192024253435374445 ],
  [ 12142729474915610162021253135384145 ],
  [ 1315283048501267161721223132394142 ], 
  [ 1114262946492378171822233233404243 ], 
  [ 1720273032353489131423243839414849 ], 
  [ 16182628313345910141524253940424950 ],
  [ 17192729323415610111521253640434650 ],
  [ 1820283033351267111221223637444647 ], 
  [ 1619262931342378121322233738454748 ], 
  [ 2225323537403489131418192829434446 ], 
  [ 21233133363845910141519202930444547 ],
  [ 22243234373915610111516202630414548 ],
  [ 2325333538401267111216172627414249 ], 
  [ 2124313436392378121317182728424350 ] ]

#StrongProduct
gap> D := Digraph([[22], [113], [2]]);
<immutable multidigraph with 3 vertices, 6 edges>
gap> StrongProduct(D, D);
Error, the 1st argument (a digraph) must not satisfy IsMultiDigraph
gap> DigraphSymmetricClosure(ChainDigraph(6));
<immutable symmetric digraph with 6 vertices, 10 edges>
gap> StrongProduct(DigraphSymmetricClosure(ChainDigraph(10)), last);
<immutable digraph with 60 vertices, 388 edges>
gap> StrongProduct(NullDigraph(0), CompleteDigraph(5));
<immutable empty digraph with 0 vertices>
gap>  DigraphSymmetricClosure(CycleDigraph(4));
<immutable symmetric digraph with 4 vertices, 8 edges>
gap> StrongProduct(DigraphSymmetricClosure(ChainDigraph(3)), last);
<immutable digraph with 12 vertices, 72 edges>
gap> OutNeighbours(last);
[ [ 24568 ], [ 13567 ], [ 24678 ], [ 13578 ], 
  [ 1246891012 ], [ 1235791011 ], 
  [ 23468101112 ], [ 1345791112 ], 
  [ 5681012 ], [ 567911 ], [ 6781012 ], 
  [ 578911 ] ]
gap> StrongProduct(ChainDigraph(2), ChainDigraph(8));
<immutable digraph with 16 vertices, 29 edges>

#ConormalProduct
gap> D := Digraph([[244], [13], [24], [113]]);
<immutable multidigraph with 4 vertices, 10 edges>
gap> ConormalProduct(D, D);
Error, the 1st argument (a digraph) must not satisfy IsMultiDigraph
gap> ConormalProduct(NullDigraph(10), CompleteDigraph(10));
<immutable digraph with 100 vertices, 9000 edges>
gap> ConormalProduct(PetersenGraph(), PetersenGraph());
<immutable digraph with 100 vertices, 5100 edges>
gap> DigraphSymmetricClosure(CycleDigraph(3));
<immutable symmetric digraph with 3 vertices, 6 edges>
gap> ConormalProduct(last, last);
<immutable digraph with 9 vertices, 72 edges>
gap> ConormalProduct(CycleDigraph(2), CycleDigraph(8));
<immutable digraph with 16 vertices, 144 edges>

#HomomorphicProduct
gap> D := Digraph([[23], [133], [122]]);
<immutable multidigraph with 3 vertices, 8 edges>
gap> HomomorphicProduct(D, D);                    
Error, the 1st argument (a digraph) must not satisfy IsMultiDigraph
gap> DigraphSymmetricClosure(CycleDigraph(6)); 
<immutable symmetric digraph with 6 vertices, 12 edges>
gap> HomomorphicProduct(PetersenGraph(), last);
<immutable digraph with 60 vertices, 1080 edges>
gap> HomomorphicProduct(NullDigraph(0), CompleteDigraph(11));
<immutable empty digraph with 0 vertices>
gap> DigraphSymmetricClosure(CycleDigraph(8));
<immutable symmetric digraph with 8 vertices, 16 edges>
gap> HomomorphicProduct(NullDigraph(10), last);
<immutable digraph with 80 vertices, 640 edges>
gap> OutNeighbours(last);
[ [ 12345678 ], [ 12345678 ], 
  [ 12345678 ], [ 12345678 ], 
  [ 12345678 ], [ 12345678 ], 
  [ 12345678 ], [ 12345678 ], 
  [ 910111213141516 ], [ 910111213141516 ], 
  [ 910111213141516 ], [ 910111213141516 ], 
  [ 910111213141516 ], [ 910111213141516 ], 
  [ 910111213141516 ], [ 910111213141516 ], 
  [ 1718192021222324 ], [ 1718192021222324 ], 
  [ 1718192021222324 ], [ 1718192021222324 ], 
  [ 1718192021222324 ], [ 1718192021222324 ], 
  [ 1718192021222324 ], [ 1718192021222324 ], 
  [ 2526272829303132 ], [ 2526272829303132 ], 
  [ 2526272829303132 ], [ 2526272829303132 ], 
  [ 2526272829303132 ], [ 2526272829303132 ], 
  [ 2526272829303132 ], [ 2526272829303132 ], 
  [ 3334353637383940 ], [ 3334353637383940 ], 
  [ 3334353637383940 ], [ 3334353637383940 ], 
  [ 3334353637383940 ], [ 3334353637383940 ], 
  [ 3334353637383940 ], [ 3334353637383940 ], 
  [ 4142434445464748 ], [ 4142434445464748 ], 
  [ 4142434445464748 ], [ 4142434445464748 ], 
  [ 4142434445464748 ], [ 4142434445464748 ], 
  [ 4142434445464748 ], [ 4142434445464748 ], 
  [ 4950515253545556 ], [ 4950515253545556 ], 
  [ 4950515253545556 ], [ 4950515253545556 ], 
  [ 4950515253545556 ], [ 4950515253545556 ], 
  [ 4950515253545556 ], [ 4950515253545556 ], 
  [ 5758596061626364 ], [ 5758596061626364 ], 
  [ 5758596061626364 ], [ 5758596061626364 ], 
  [ 5758596061626364 ], [ 5758596061626364 ], 
  [ 5758596061626364 ], [ 5758596061626364 ], 
  [ 6566676869707172 ], [ 6566676869707172 ], 
  [ 6566676869707172 ], [ 6566676869707172 ], 
  [ 6566676869707172 ], [ 6566676869707172 ], 
  [ 6566676869707172 ], [ 6566676869707172 ], 
  [ 7374757677787980 ], [ 7374757677787980 ], 
  [ 7374757677787980 ], [ 7374757677787980 ], 
  [ 7374757677787980 ], [ 7374757677787980 ], 
  [ 7374757677787980 ], [ 7374757677787980 ] ]
gap> HomomorphicProduct(CompleteDigraph(8), CycleDigraph(8));
<immutable digraph with 64 vertices, 3648 edges>

#LexicographicProduct
gap> D := Digraph([[222], [111]]);
<immutable multidigraph with 2 vertices, 6 edges>
gap> LexicographicProduct(CompleteDigraph(3), D);
Error, the 2nd argument (a digraph) must not satisfy IsMultiDigraph
gap> StrongProduct(NullDigraph(0), CompleteDigraph(3));
<immutable empty digraph with 0 vertices>
gap> D1 := Digraph([[2], [134], [25], [25], [34]]);
<immutable digraph with 5 vertices, 10 edges>
gap> D2 := Digraph([[2], [134], [2], [2]]);              
<immutable digraph with 4 vertices, 6 edges>
gap> LexicographicProduct(D1, D2);
<immutable digraph with 20 vertices, 190 edges>
gap> OutNeighbours(last);
[ [ 25678 ], [ 1345678 ], [ 25678 ], 
  [ 25678 ], [ 12346910111213141516 ], 
  [ 1234578910111213141516 ], 
  [ 12346910111213141516 ], 
  [ 12346910111213141516 ], 
  [ 56781017181920 ], 
  [ 56789111217181920 ], 
  [ 56781017181920 ], [ 56781017181920 ], 
  [ 56781417181920 ], 
  [ 567813151617181920 ], 
  [ 56781417181920 ], [ 56781417181920 ], 
  [ 91011121314151618 ], 
  [ 910111213141516171920 ], 
  [ 91011121314151618 ], 
  [ 91011121314151618 ] ]
gap> LexicographicProduct(ChainDigraph(3), CycleDigraph(7));   
<immutable digraph with 21 vertices, 119 edges>

# DigraphShortestPathSpanningTree
gap> D := Digraph([[234], [1345], [12], [5], [4]]);
<immutable digraph with 5 vertices, 11 edges>
gap> OutNeighbours(DigraphShortestPathSpanningTree(D, 1));
[ [ 234 ], [ 5 ], [  ], [  ], [  ] ]
gap> OutNeighbours(DigraphShortestPathSpanningTree(D, 2));
[ [  ], [ 1345 ], [  ], [  ], [  ] ]
gap> OutNeighbours(DigraphShortestPathSpanningTree(D, 3));
[ [ 4 ], [ 5 ], [ 12 ], [  ], [  ] ]
gap> DigraphShortestPathSpanningTree(D, 4);
fail
gap> DigraphShortestPathSpanningTree(D, 5);
fail
gap> OutNeighbours(DigraphShortestPathSpanningTree(D, 6));
Error, the 2nd argument <v> must be a vertex of the digraph <D>

#
gap> D1 := Digraph([[], [1], [24], [5], []]);
<immutable digraph with 5 vertices, 4 edges>
gap> SetDigraphVertexLabels(D1, Elements(CyclicGroup(IsPermGroup, 5)));
gap> DigraphGroup(D1);
Group([ (1,5)(2,4) ])
gap> D2 := DigraphShortestPathSpanningTree(D1, 3);;
gap> D1 = D2;
true
gap> DigraphVertexLabels(D2);
[ (), (1,2,3,4,5), (1,3,5,2,4), (1,4,2,5,3), (1,5,4,3,2) ]
gap> IsDirectedTree(D2);
true

#
gap> D1 := DigraphFromDigraph6String("&GG@STD?eIA?_");
<immutable digraph with 8 vertices, 16 edges>
gap> SetDigraphVertexLabels(D1, "abcdefgh");
gap> g := AsList(DihedralGroup(IsPermGroup, 16));;
gap> for i in [1 .. DigraphNrEdges(D1)] do
>   e := DigraphEdges(D1)[i];
>   SetDigraphEdgeLabel(D1, e[1], e[2], g[i]);
> od;
gap> D2 := DigraphMutableCopy(D1);
<mutable digraph with 8 vertices, 16 edges>
gap> DigraphShortestPathSpanningTree(D2, 1);
fail
gap> DigraphShortestPathSpanningTree(D2, 2);;
gap> D2;
<mutable digraph with 8 vertices, 7 edges>
gap> for i in [1 .. DigraphNrEdges(D2)] do
>   e := DigraphEdges(D2)[i];
>   if DigraphEdgeLabel(D1, e[1], e[2]) <> DigraphEdgeLabel(D1, e[1], e[2]) then
>     Print("fail!");
>   fi;
> od;
gap> DigraphVertexLabels(D2);
"abcdefgh"
gap> OutNeighbours(D2);
[ [ 3 ], [ 468 ], [  ], [  ], [  ], [ 157 ], [  ], [  ] ]
gap> IsDirectedTree(D2);
true

#
gap> DigraphShortestPathSpanningTree(EmptyDigraph(0), 1);
Error, the 2nd argument <v> must be a vertex of the digraph <D>
gap> DigraphShortestPathSpanningTree(EmptyDigraph(1), 1);
<immutable empty digraph with 1 vertex>

# Dominators
gap> D := Digraph([[2], [346], [5], [5], [2], []]);
<immutable digraph with 6 vertices, 7 edges>
gap> D := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> D := DigraphDisjointUnion(D, D);
<immutable digraph with 10 vertices, 40 edges>
gap> D := NullDigraph(10);
<immutable empty digraph with 10 vertices>
gap> D := ChainDigraph(10000);
<immutable chain digraph with 10000 vertices>
gap> D := Digraph([[123], [4], [15], [], [2]]);;
gap> D := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> Dominators(D, 1);
[ , [ 1 ], [ 1 ], [ 1 ], [ 1 ] ]
gap> Dominators(D, 2);
[ [ 2 ],, [ 2 ], [ 2 ], [ 2 ] ]
gap> Dominators(D, 5);
[ [ 5 ], [ 5 ], [ 5 ], [ 5 ] ]
gap> D := CycleDigraph(10);
<immutable cycle digraph with 10 vertices>
gap> Dominators(D, 5);
[ [ 1098765 ], [ 11098765 ], 
  [ 211098765 ], [ 3211098765 ],, [ 5 ], 
  [ 65 ], [ 765 ], [ 8765 ], [ 98765 ] ]
gap> D := Digraph([[34], [14], [25], [35], []]);
<immutable digraph with 5 vertices, 8 edges>
gap> Dominators(D, 1);
[ , [ 31 ], [ 1 ], [ 1 ], [ 1 ] ]
gap> Dominators(D, 2);
[ [ 2 ],, [ 2 ], [ 2 ], [ 2 ] ]
gap> Dominators(D, 3);
[ [ 23 ], [ 3 ],, [ 23 ], [ 3 ] ]
gap> Dominators(D, 4);
[ [ 234 ], [ 34 ], [ 4 ],, [ 4 ] ]
gap> Dominators(D, 5);
[  ]
gap> d := Digraph([[23], [46], [45], [35], [16], [23]]);
<immutable digraph with 6 vertices, 12 edges>
gap> Dominators(d, 5);
[ [ 5 ], [ 5 ], [ 5 ], [ 5 ],, [ 5 ] ]
gap> Dominators(d, 1);
[ , [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ] ]
gap> Dominators(d, 3);
[ [ 53 ], [ 53 ],, [ 3 ], [ 3 ], [ 53 ] ]
gap> Dominators(d, 4);
[ [ 54 ], [ 54 ], [ 4 ],, [ 4 ], [ 54 ] ]
gap> Dominators(d, 6);
[ [ 56 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ] ]
gap> d := Digraph([[], [3], [45], [2], [4]]);
<immutable digraph with 5 vertices, 5 edges>
gap> Dominators(d, 1);
[  ]
gap> Dominators(d, 2);
[ ,, [ 2 ], [ 32 ], [ 32 ] ]
gap> Dominators(d, 3);
[ , [ 43 ],, [ 3 ], [ 3 ] ]
gap> Dominators(d, 4);
[ , [ 4 ], [ 24 ],, [ 324 ] ]
gap> Dominators(d, 5);
[ , [ 45 ], [ 245 ], [ 5 ] ]
gap> D := Digraph([[235], [16], [467], [78], [4], [], [8], []]);
<immutable digraph with 8 vertices, 12 edges>
gap> Dominators(D, 1);
[ , [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ] ]
gap> Dominators(D, 2);
[ [ 2 ],, [ 12 ], [ 12 ], [ 12 ], [ 2 ], [ 12 ], [ 12 ] ]
gap> Dominators(D, 3);
[ ,,, [ 3 ],, [ 3 ], [ 3 ], [ 3 ] ]
gap> Dominators(D, 4);
[ ,,,,,, [ 4 ], [ 4 ] ]
gap> Dominators(D, 5);
[ ,,, [ 5 ],,, [ 45 ], [ 45 ] ]
gap> Dominators(D, 6);
[  ]
gap> Dominators(D, 7);
[ ,,,,,,, [ 7 ] ]
gap> Dominators(D, 8);
[  ]
gap> d := Digraph([[2], [36], [24], [1], [], [3]]);
<immutable digraph with 6 vertices, 7 edges>
gap> Dominators(d, 1);
[ , [ 1 ], [ 21 ], [ 321 ],, [ 21 ] ]
gap> Dominators(d, 2);
[ [ 432 ],, [ 2 ], [ 32 ],, [ 2 ] ]
gap> Dominators(d, 3);
[ [ 43 ], [ 3 ],, [ 3 ],, [ 23 ] ]
gap> Dominators(d, 4);
[ [ 4 ], [ 14 ], [ 214 ],,, [ 214 ] ]
gap> Dominators(d, 5);
[  ]
gap> Dominators(d, 6);
[ [ 436 ], [ 36 ], [ 6 ], [ 36 ] ]
gap> d := Digraph([[123], [45], [13], [35], [4]]);
<immutable digraph with 5 vertices, 10 edges>
gap> Dominators(d, 1);
[ , [ 1 ], [ 1 ], [ 21 ], [ 21 ] ]
gap> Dominators(d, 2);
[ [ 342 ],, [ 42 ], [ 2 ], [ 2 ] ]
gap> Dominators(d, 3);
[ [ 3 ], [ 13 ],, [ 213 ], [ 213 ] ]
gap> Dominators(d, 4);
[ [ 34 ], [ 134 ], [ 4 ],, [ 4 ] ]
gap> Dominators(d, 5);
[ [ 345 ], [ 1345 ], [ 45 ], [ 5 ] ]
gap>  D := Digraph([[123], [4], [15], [], [2]]);
<immutable digraph with 5 vertices, 7 edges>
gap> Dominators(D, 1);
[ , [ 1 ], [ 1 ], [ 21 ], [ 31 ] ]
gap> Dominators(D, 2);
[ ,,, [ 2 ] ]
gap> Dominators(D, 3);
[ [ 3 ], [ 3 ],, [ 23 ], [ 3 ] ]
gap> Dominators(D, 4);
[  ]
gap> Dominators(D, 5);
[ , [ 5 ],, [ 25 ] ]
gap> D := EmptyDigraph(15);
<immutable empty digraph with 15 vertices>
gap> Dominators(D, 3);
[  ]
gap> D := Digraph(IsMutableDigraph, [[123], [4], [15], [], [2]]);
<mutable digraph with 5 vertices, 7 edges>
gap> Dominators(D, 5);
[ , [ 5 ],, [ 25 ] ]
gap> Dominators(D, 4);
[  ]
gap> Dominators(D, 3);
[ [ 3 ], [ 3 ],, [ 23 ], [ 3 ] ]
gap> Dominators(D, 2);
[ ,,, [ 2 ] ]
gap> Dominators(D, 1);
[ , [ 1 ], [ 1 ], [ 21 ], [ 31 ] ]
gap> D := Digraph(IsMutableDigraph, [[235], [16], [467], [78], [4],
> [], [8], []]);
<mutable digraph with 8 vertices, 12 edges>
gap> Dominators(D, 1);
[ , [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ] ]
gap> Dominators(D, 2);
[ [ 2 ],, [ 12 ], [ 12 ], [ 12 ], [ 2 ], [ 12 ], [ 12 ] ]
gap> Dominators(D, 3);
[ ,,, [ 3 ],, [ 3 ], [ 3 ], [ 3 ] ]
gap> Dominators(D, 4);
[ ,,,,,, [ 4 ], [ 4 ] ]
gap> Dominators(D, 5);
[ ,,, [ 5 ],,, [ 45 ], [ 45 ] ]
gap> Dominators(D, 6);
[  ]
gap> Dominators(D, 7);
[ ,,,,,,, [ 7 ] ]
gap> Dominators(D, 8);
[  ]

# DominatorTree
gap> D := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> DominatorTree(D, 1);
rec( idom := [ fail, 1111 ], preorder := [ 12345 ] )
gap> DominatorTree(D, 2);
rec( idom := [ 2, fail, 222 ], preorder := [ 21345 ] )
gap> DominatorTree(D, 3);
rec( idom := [ 33, fail, 33 ], preorder := [ 31245 ] )
gap> DominatorTree(D, 4);
rec( idom := [ 444, fail, 4 ], preorder := [ 41235 ] )
gap> DominatorTree(D, 5);
rec( idom := [ 5555, fail ], preorder := [ 51234 ] )
gap> D := CycleDigraph(10);
<immutable cycle digraph with 10 vertices>
gap> DominatorTree(D, 1);
rec( idom := [ fail, 123456789 ], 
  preorder := [ 12345678910 ] )
gap> DominatorTree(D, 2);
rec( idom := [ 10, fail, 23456789 ], 
  preorder := [ 23456789101 ] )
gap> DominatorTree(D, 5);
rec( idom := [ 10123, fail, 56789 ], 
  preorder := [ 56789101234 ] )
gap> D := Digraph([[23], [46], [45], [35], [16], [23]]);
<immutable digraph with 6 vertices, 12 edges>
gap> DominatorTree(D, 1);
rec( idom := [ fail, 11111 ], preorder := [ 124356 ] )
gap> DominatorTree(D, 5);
rec( idom := [ 5555, fail, 5 ], preorder := [ 512436 ] )
gap> DominatorTree(D, 6);
rec( idom := [ 56666, fail ], preorder := [ 624351 ] )
gap> D := EmptyDigraph(15);
<immutable empty digraph with 15 vertices>
gap> DominatorTree(D, 1);
rec( idom := [ fail ], preorder := [ 1 ] )
gap> DominatorTree(D, 6);
rec( idom := [ ,,,,, fail ], preorder := [ 6 ] )

# IsDigraphPath
gap> D := Digraph(IsMutableDigraph, Combinations([1 .. 5]), IsSubset);
<mutable digraph with 32 vertices, 243 edges>
gap> DigraphReflexiveTransitiveReduction(D);
<mutable digraph with 32 vertices, 80 edges>
gap> MakeImmutable(D);
<immutable digraph with 32 vertices, 80 edges>
gap> IsDigraphPath(D, []);
Error, the 2nd argument (a list) must have length 2, but found length 0
gap> IsDigraphPath(D, [123], []);
Error, the 2nd and 3rd arguments (lists) are incompatible, expected 3rd argume\
nt of length 2, got 0
gap> IsDigraphPath(D, [1], []);
true
gap> IsDigraphPath(D, [12], [5]);
false
gap> IsDigraphPath(D, [323133], [11]);
false
gap> IsDigraphPath(D, [323331], [11]);
false
gap> IsDigraphPath(D, [691617], [332]);
true
gap> IsDigraphPath(D, [3391617], [332]);
false
gap> IsDigraphPath(D, [69181], [9102]);
false
gap> IsDigraphPath(D, DigraphPath(D, 61));
true
gap> ForAll(List(IteratorOfPaths(D, 61)), x -> IsDigraphPath(D, x));
true

# IsDigraphPath: failing example with new DFS code (issue #487)
gap> D := Digraph([
>   [23455], [63475], [8910811],
>   [1213141516], [21341217], [6941611],
>   [18134128], [819101920], [8910821],
>   [1213141516], [2213141216], [231324128],
>   [19919824], [1913191516], [2119241920],
>   [251310128], [2613101217], [634727],
>   [1919191919], [2813191216], [2913141216],
>   [23324730], [299141624], [1219141919],
>   [88102415], [88102431], [301941920],
>   [198192412], [239241621], [61341217],
>   [3213241217], [2931477]]);;
gap> path := DigraphPath(D, 55);;
gap> IsDigraphPath(D, path);
true
gap> D1 := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> D2 := CompleteDigraph(10);
<immutable complete digraph with 10 vertices>
gap> VerticesReachableFrom(D1, [1]);
12345 ]
gap> VerticesReachableFrom(D1, [12]);
12345 ]
gap> VerticesReachableFrom(D2, [1]);
12345678910 ]
gap> VerticesReachableFrom(D2, [111]);
Error, an element of the 2nd argument (roots) is not a vertex of the 1st argum\
ent (a digraph)
gap> D3 := CompleteDigraph(7);
<immutable complete digraph with 7 vertices>
gap> D3_edges := [1 .. 7];
1 .. 7 ]
gap> for i in D3_edges do
>      D3 := DigraphRemoveEdge(D3, [1, i]);
>      D3 := DigraphRemoveEdge(D3, [i, 1]);
>    od;
gap> VerticesReachableFrom(D3, [1]);
[  ]
gap> TestPartialOrderDigraph := Digraph([[13], [23], [3]]);
<immutable digraph with 3 vertices, 5 edges>
gap> IsOrderIdeal(TestPartialOrderDigraph, [123]);
true
gap> TestPartialOrderDigraph2 := Digraph([[13], [23], [3]]);
<immutable digraph with 3 vertices, 5 edges>
gap> TestUnion := DigraphDisjointUnion(TestPartialOrderDigraph, TestPartialOrderDigraph2);
<immutable digraph with 6 vertices, 10 edges>
gap> IsOrderIdeal(TestUnion, [123]);
true
gap> IsOrderIdeal(TestUnion, [456]);
true
gap> IsOrderIdeal(TestUnion, [156]);
false
gap> D := CycleDigraph(5);;
gap> IsOrderIdeal(D, [1]);
Error, the 1st argument (a digraph) must be a partial order digraph

# IsOrderFilter
gap> D := DigraphByEdges([[11], [12], [13], [23], [33], [22], [24], [44], [14]]);
<immutable digraph with 4 vertices, 9 edges>
gap> IsOrderFilter(D, [12]);
true
gap> IsOrderFilter(D, [23]);
false
gap> IsOrderFilter(D, [14]);
false
gap> IsOrderFilter(D, [4]);
false
gap> IsOrderFilter(4);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsOrderFilter' on 1 arguments
gap> IsOrderFilter(D, 4);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsOrderFilter' on 2 arguments
gap> IsOrderFilter(D, [5]);
Error, an element of the 2nd argument (roots) is not a vertex of the 1st argum\
ent (a digraph)

# DigraphCycleBasis
gap> D := NullDigraph(0);
<immutable empty digraph with 0 vertices>
gap> DigraphCycleBasis(D);
[ [  ], [  ] ]
gap> D := NullDigraph(6);
<immutable empty digraph with 6 vertices>
gap> DigraphCycleBasis(D);
[ [ [  ], [  ], [  ], [  ], [  ], [  ] ], [  ] ]
gap> D := Digraph([[1]]);
<immutable digraph with 1 vertex, 1 edge>
gap> DigraphCycleBasis(D);
Error, the 1st argument (a digraph) must not have any loops
gap> D := CompleteDigraph(5);
<immutable complete digraph with 5 vertices>
gap> res := DigraphCycleBasis(D);
[ [ [ 2345 ], [ 345 ], [ 45 ], [ 5 ], [  ] ], 
  [ <a GF2 vector of length 10>, <a GF2 vector of length 10>, 
      <a GF2 vector of length 10>, <a GF2 vector of length 10>, 
      <a GF2 vector of length 10>, <a GF2 vector of length 10> ] ]
gap> List(res[2], List);
[ [ Z(2)^00*Z(2), 0*Z(2), Z(2)^00*Z(2), 0*Z(2), Z(2)^00*Z(2), 0*Z(2), 
      0*Z(2) ], 
  [ 0*Z(2), Z(2)^00*Z(2), Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0
      0*Z(2) ], 
  [ 0*Z(2), 0*Z(2), Z(2)^0, Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 
      Z(2)^0 ], 
  [ Z(2)^00*Z(2), Z(2)^00*Z(2), 0*Z(2), Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 
      0*Z(2) ], 
  [ 0*Z(2), Z(2)^0, Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^00*Z(2), 
      0*Z(2) ], 
  [ Z(2)^0, Z(2)^00*Z(2), 0*Z(2), Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 
      0*Z(2) ] ]
gap> D := DigraphSymmetricClosure(ChainDigraph(10));
<immutable symmetric digraph with 10 vertices, 18 edges>
gap> DigraphCycleBasis(D);
[ [ [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [  ] ], 
  [  ] ]
gap> D := Digraph([[6], [316], [2], [65], [4326], [4152]]);
<immutable digraph with 6 vertices, 15 edges>
gap> res := DigraphCycleBasis(D);
[ [ [ 6 ], [ 136 ], [  ], [ 56 ], [ 236 ], [  ] ], 
  [ <a GF2 vector of length 9>, <a GF2 vector of length 9>, 
      <a GF2 vector of length 9>, <a GF2 vector of length 9> ] ]
gap> List(res[2], List);
[ [ Z(2)^0, Z(2)^00*Z(2), Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2) ], 
  [ 0*Z(2), 0*Z(2), Z(2)^00*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, Z(2)^00*Z(2) ], 
  [ Z(2)^0, Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^00*Z(2), Z(2)^0 ], 
  [ Z(2)^0, Z(2)^00*Z(2), 0*Z(2), Z(2)^0, Z(2)^0, Z(2)^00*Z(2), 0*Z(2) ] ]
gap> D := DigraphDisjointUnion(CycleGraph(3), CycleGraph(4));
<immutable digraph with 7 vertices, 14 edges>
gap> res := DigraphCycleBasis(D);
[ [ [ 23 ], [ 3 ], [  ], [ 57 ], [ 6 ], [ 7 ], [  ] ], 
  [ <a GF2 vector of length 7>, <a GF2 vector of length 7> ] ]
gap> List(res[2], List);
[ [ Z(2)^0, Z(2)^0, Z(2)^00*Z(2), 0*Z(2), 0*Z(2), 0*Z(2) ], 
  [ 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0 ] ]

# DigraphContractEdge

# DigraphContractEdge: wrong length list
gap> D := Digraph([[233], [2], [1]]);;
gap> DigraphContractEdge(D, [1]);
Error, the 2nd argument <edge> must be a list of length 2

# DigraphContractEdge: multi digraphs
gap> D := Digraph([[233], [2], [1]]);;
gap> DigraphContractEdge(D, 13);
Error, The 1st argument (a digraph) must not satisfy IsMultiDigraph

# DigraphContractEdge: Edge does not exist
gap> D := DigraphByEdges([[12], [21]]);;
gap> DigraphContractEdge(D, 13);
Error, expected an edge between the 2nd and 3rd arguments (vertices) 1 and 
3 but found none

# DigraphContractEdge: Edge is a looped edge (u = v)
gap> D := DigraphByEdges([[11], [21], [12]]);;
gap> DigraphVertexLabels(D);; 
gap> C := DigraphContractEdge(D, 11);
Error, The 2nd argument <u> must not be equal to the 3rd argument <v>
gap> DigraphHasLoops(D);
true
gap> DigraphEdges(D);
[ [ 11 ], [ 21 ], [ 12 ] ]
gap> DigraphVertexLabels(D);
12 ]

# DigraphContractEdge: Loop contracting to an empty Digraph
gap> D := DigraphByEdges([[12], [21]]);;
gap> SetDigraphVertexLabel(D, 1, "1");;
gap> SetDigraphVertexLabel(D, 2, "2");;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[  ]
gap> DigraphVertices(C);
1 ]
gap> DigraphVertexLabel(C, 1);
[ "2", "1" ]

# DigraphContractEdge: Double loop contracting, one edge result
gap> D := DigraphByEdges([[12], [13], [21]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 21 ] ]
gap> DigraphVertices(C);
12 ]
gap> DigraphVertexLabels(C);
3, [ 21 ] ]

# DigraphContractEdge: Loop contracting, leaving another loop remaining
gap> D := DigraphByEdges([[12], [13], [31], [21]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 12 ], [ 21 ] ]
gap> DigraphVertices(C);
12 ]
gap> DigraphVertexLabels(C);
3, [ 21 ] ]

# DigraphContractEdge: Test with a larger graph, vertex labels and an edge label, making sure D was not modified
gap> D := DigraphByEdges([[21], [13], [31], [42], [45], [34], [53]]);;
gap> SetDigraphVertexLabels(D, ["1", "2", "3", "4", "5"]);;
gap> SetDigraphEdgeLabel(D, 21, "newlabel");
gap> C := DigraphContractEdge(D, 34);;
gap> DigraphEdges(C);
[ [ 14 ], [ 21 ], [ 34 ], [ 41 ], [ 42 ], [ 43 ] ]
gap> DigraphVertexLabels(C);
[ "1", "2", "5", [ "3", "4" ] ]
gap> DigraphEdgeLabel(C, 21);
"newlabel"
gap> DigraphEdges(D);
[ [ 21 ], [ 13 ], [ 31 ], [ 42 ], [ 45 ], [ 34 ], [ 53 ] ]
gap> DigraphVertices(D);
1 .. 5 ]
gap> DigraphVertexLabels(D);
[ "1", "2", "3", "4", "5" ]

# DigraphContractEdge: Test with a loop (u, u)
gap> D := DigraphByEdges([[12], [23], [34], [41], [11]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 12);;
gap> DigraphEdges(C);
[ [ 12 ], [ 23 ], [ 33 ], [ 31 ] ]
gap> DigraphVertices(C);
1 .. 3 ]
gap> DigraphVertexLabels(C);
34, [ 12 ] ]

# DigraphContractEdge: Test with a loop (w, w)
gap> D := DigraphByEdges([[12], [23], [34], [41], [11], [21]]);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 12 ], [ 23 ], [ 33 ], [ 31 ] ]
gap> DigraphVertices(C);
1 .. 3 ]

# DigraphContractEdge: Test with a loop (w, w)
gap> D := DigraphByEdges([[12], [23], [34], [41], [11], [21]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 12 ], [ 23 ], [ 33 ], [ 31 ] ]
gap> DigraphVertices(C);
1 .. 3 ]
gap> DigraphVertexLabels(C);
34, [ 21 ] ]

# DigraphContractEdge: Test with a single edge (u, v)
gap> D := DigraphByEdges([[12]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 12);;
gap> DigraphEdges(C);
[  ]
gap> DigraphVertices(C);
1 ]
gap> DigraphVertexLabels(C);
[ [ 12 ] ]

# DigraphContractEdge: Test with a single node, with one loop, and one incident edge
gap> D := DigraphByEdges([[11], [21]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 11 ] ]
gap> DigraphVertices(C);
1 ]
gap> DigraphVertexLabels(C);
[ [ 21 ] ]

# DigraphContractEdge: Standard test
gap> D := DigraphByEdges([[21], [31], [34], [14], [42], [52], [45], [55]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 21);;
gap> DigraphEdges(C);
[ [ 14 ], [ 12 ], [ 24 ], [ 23 ], [ 34 ], [ 33 ], [ 42 ] ]
gap> DigraphVertices(C);
1 .. 4 ]
gap> DigraphVertexLabels(C);
345, [ 21 ] ]

# DigraphContractEdge: Standard test (list)
gap> D := DigraphByEdges([[21], [31], [34], [14], [42], [52], [45], [55]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, [21]);;
gap> DigraphEdges(C);
[ [ 14 ], [ 12 ], [ 24 ], [ 23 ], [ 34 ], [ 33 ], [ 42 ] ]
gap> DigraphVertices(C);
1 .. 4 ]
gap> DigraphVertexLabels(C);
345, [ 21 ] ]

# DigraphContractEdge: Disconnected test
gap> D := DigraphByEdges([[12], [13], [21], [22], [23], [32], [44], [45], [46], [55], [54]]);;
gap> DigraphVertexLabels(D);;
gap> C := DigraphContractEdge(D, 45);;
gap> DigraphEdges(C);
[ [ 12 ], [ 13 ], [ 21 ], [ 22 ], [ 23 ], [ 32 ], [ 55 ], 
  [ 54 ] ]
gap> DigraphVertexLabels(C);
1236, [ 45 ] ]

# DigraphContractEdge: wrong length list (mutable
gap> D := Digraph(IsMutableDigraph, [[233], [2], [1]]);;
gap> DigraphContractEdge(D, [1]);
Error, the 2nd argument <edge> must be a list of length 2

# DigraphContractEdge: MultiDigraph (mutable)
gap> D := Digraph(IsMutableDigraph, [[233], [2], [1]]);;
gap> DigraphContractEdge(D, 13);
Error, The 1st argument (a digraph) must not satisfy IsMultiDigraph

# DigraphContractEdge: Edge does not exist (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [21]]);;
gap> DigraphContractEdge(D, 13);
Error, expected an edge between the 2nd and 3rd arguments (vertices) 1 and 
3 but found none

# DigraphContractEdge: Edge is a looped edge (u = v) (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[11], [21], [12]]);;
gap> DigraphVertexLabels(D);; 
gap> DigraphContractEdge(D, 11);
Error, The 2nd argument <u> must not be equal to the 3rd argument <v>
gap> DigraphHasLoops(D);
true
gap> DigraphEdges(D);
[ [ 11 ], [ 12 ], [ 21 ] ]
gap> DigraphVertexLabels(D);
12 ]

# DigraphContractEdge: Loop contracting to an empty Digraph (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [21]]);;
gap> SetDigraphVertexLabel(D, 1, "1");;
gap> SetDigraphVertexLabel(D, 2, "2");;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[  ]
gap> DigraphVertices(D);
1 ]
gap> DigraphVertexLabel(D, 1);
[ "2", "1" ]

# DigraphContractEdge: Double loop contracting, one edge result (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [13], [21]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[ [ 21 ] ]
gap> DigraphVertices(D);
12 ]
gap> DigraphVertexLabels(D);
3, [ 21 ] ]

# DigraphContractEdge: Loop contracting, leaving another loop remaining (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [13], [31], [21]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[ [ 12 ], [ 21 ] ]
gap> DigraphVertices(D);
12 ]
gap> DigraphVertexLabels(D);
3, [ 21 ] ]

# DigraphContractEdge: Test with a larger graph, vertex labels and an edge label (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[21], [13], [31], [42], [45], [34], [53]]);;
gap> SetDigraphVertexLabels(D, ["1", "2", "3", "4", "5"]);;
gap> SetDigraphEdgeLabel(D, 21, "newlabel");
gap> DigraphContractEdge(D, 34);;
gap> DigraphEdges(D);
[ [ 14 ], [ 21 ], [ 34 ], [ 41 ], [ 42 ], [ 43 ] ]
gap> DigraphVertexLabels(D);
[ "1", "2", "5", [ "3", "4" ] ]
gap> DigraphEdgeLabel(D, 21);
"newlabel"

# DigraphContractEdge: Test with a loop (u, u) (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [23], [34], [41], [11]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 12);;
gap> DigraphEdges(D);
[ [ 12 ], [ 23 ], [ 33 ], [ 31 ] ]
gap> DigraphVertices(D);
1 .. 3 ]
gap> DigraphVertexLabels(D);
34, [ 12 ] ]

# DigraphContractEdge: Test with a loop (w, w) (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [23], [34], [41], [11], [21]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[ [ 12 ], [ 23 ], [ 33 ], [ 31 ] ]
gap> DigraphVertices(D);
1 .. 3 ]
gap> DigraphVertexLabels(D);
34, [ 21 ] ]

# DigraphContractEdge: Test with a single edge (u, v) (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 12);;
gap> DigraphEdges(D);
[  ]
gap> DigraphVertices(D);
1 ]
gap> DigraphVertexLabels(D);
[ [ 12 ] ]

# DigraphContractEdge: Test with a single node, with one loop, and one incident edge (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[11], [21]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[ [ 11 ] ]
gap> DigraphVertices(D);
1 ]
gap> DigraphVertexLabels(D);
[ [ 21 ] ]

# DigraphContractEdge: Standard test (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[21], [31], [34], [14], [42], [52], [45], [55]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 21);;
gap> DigraphEdges(D);
[ [ 12 ], [ 14 ], [ 23 ], [ 24 ], [ 33 ], [ 34 ], [ 42 ] ]
gap> DigraphVertexLabels(D);
345, [ 21 ] ]

# DigraphContractEdge: Standard test (list, mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[21], [31], [34], [14], [42], [52], [45], [55]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, [21]);;
gap> DigraphEdges(D);
[ [ 12 ], [ 14 ], [ 23 ], [ 24 ], [ 33 ], [ 34 ], [ 42 ] ]
gap> DigraphVertexLabels(D);
345, [ 21 ] ]

# DigraphContractEdge: Disconnected test (mutable)
gap> D := DigraphByEdges(IsMutableDigraph, [[12], [13], [21], [22], [23], [32], [44], [45], [46], [55], [54]]);;
gap> DigraphVertexLabels(D);;
gap> DigraphContractEdge(D, 45);;
gap> DigraphEdges(D);
[ [ 12 ], [ 13 ], [ 21 ], [ 22 ], [ 23 ], [ 32 ], [ 55 ], 
  [ 54 ] ]
gap> DigraphVertexLabels(D);
1236, [ 45 ] ]

#
gap> DIGRAPHS_StopTest();
gap> STOP_TEST("Digraphs package: standard/oper.tst", 0);

[zur Elbe Produktseite wechseln0.110QuellennavigatorsAnalyse erneut starten2026-06-16]