diff --git a/doc/attr.xml b/doc/attr.xml
index 1dd3bb640..23f846615 100644
--- a/doc/attr.xml
+++ b/doc/attr.xml
@@ -1117,6 +1117,7 @@ gap> DigraphUndirectedGirth(D);
<#GAPDoc Label="ArticulationPoints">
+
A list of vertices.
A connected digraph is biconnected if it is still connected (in the
@@ -1143,6 +1144,9 @@ gap> DigraphUndirectedGirth(D);
with articulation points, but no bridges.
+ is a synonym for .
+
+
See also and
.
DigraphWelshPowellOrder(Digraph([[4], [9], [9], [],
<#/GAPDoc>
+<#GAPDoc Label="DigraphSmallestLastOrder">
+
+
+ A list of vertices.
+
+ DigraphSmallestLastOrder returns a list order containing each
+ of the vertices of digraph in smallest-last order, defined as
+ follows:
+
+ Let D_n be digraph. For i = n, n-1, \ldots, 1, the
+ vertex order[i] is a vertex of minimum degree in D_i, and
+ D_{i-1} is the subdigraph of D_i induced by removing
+ order[i]. The degree of a vertex here is the sum of the number of
+ out- and in-neighbours.
+
+ The result is not unique in general, since there may be several vertices
+ of minimum degree at any step; DigraphSmallestLastOrder tiebreaks
+ by taking the smallest such vertex.
+ D1 := Digraph([[2], [1, 3], [2]]);;
+gap> DigraphSmallestLastOrder(D1);
+[ 3, 2, 1 ]
+gap> D2 := CompleteDigraph(3);;
+gap> DigraphSmallestLastOrder(D2);
+[ 3, 2, 1 ]
+]]>
+
+
+<#/GAPDoc>
+
<#GAPDoc Label="DigraphEmbedding">
diff --git a/doc/oper.xml b/doc/oper.xml
index 9213ec1b4..c7cf5d218 100644
--- a/doc/oper.xml
+++ b/doc/oper.xml
@@ -1957,6 +1957,7 @@ rec( idom := [ 2, fail, 2, 2, 2 ], preorder := [ 2, 1, 3, 4, 5 ] )
<#GAPDoc Label="IsDigraphOutDominatingSet">
+
true or false.
@@ -1973,7 +1974,10 @@ rec( idom := [ 2, fail, 2, 2, 2 ], preorder := [ 2, 1, 3, 4, 5 ] )
either in S or an out-neighbour of a vertex in S.
An in-dominating set of digraph is a subset S of
vertices of digraph such that every vertex of digraph is
- either in S or an in-neighbour of a vertex in S.
+ either in S or an in-neighbour of a vertex in S.
+
+ is a synonym for
+ .
D := Digraph([[2, 4], [3], [1, 5], [3], [4]]);;
@@ -2290,6 +2294,7 @@ gap> DigraphDijkstra(D, 1, 2);
<#GAPDoc Label="ModularProduct">
+
A digraph.
If D1 and D2 are digraphs without multiple edges, then
@@ -2313,7 +2318,10 @@ gap> DigraphDijkstra(D, 1, 2);
Notably, the complete (with loops) subdigraphs of MPD are
- precisely the partial isomorphisms from D1 to D2.
+ precisely the partial isomorphisms from D1 to D2.
+
+ is a synonym for
+ .
ModularProduct(Digraph([[1], [1, 2]]), Digraph([[], [2]]));
@@ -2333,6 +2341,7 @@ gap> ModularProduct(NullDigraph(0), CompleteDigraph(10));
<#GAPDoc Label="StrongProduct">
+
A digraph.
If D1 and D2 are digraphs without multiple edges,
@@ -2360,7 +2369,10 @@ gap> ModularProduct(NullDigraph(0), CompleteDigraph(10));
The SPD of two paths of lengths m and n is also the king's graph
- for an m by n board.
+ for an m by n board.
+
+ is a synonym for
+ .
D1 := Digraph([[2], [1, 3, 4], [2, 5], [2, 5], [3, 4]]);
@@ -2380,6 +2392,7 @@ gap> StrongProduct(DigraphSymmetricClosure(ChainDigraph(3)),
<#GAPDoc Label="ConormalProduct">
+
A digraph.
If D1 and D2 are digraphs without multiple edges,
@@ -2398,7 +2411,10 @@ gap> StrongProduct(DigraphSymmetricClosure(ChainDigraph(3)),
-
There is an edge from b to d in D2.
-
+
+
+ is a synonym for
+ .
ConormalProduct(DigraphSymmetricClosure(CycleDigraph(7)),
@@ -2414,6 +2430,7 @@ gap> ConormalProduct(NullDigraph(0), CompleteDigraph(10));
<#GAPDoc Label="HomomorphicProduct">
+
A digraph.
If D1 and D2 are digraphs without multiple edges,
@@ -2433,7 +2450,10 @@ gap> ConormalProduct(NullDigraph(0), CompleteDigraph(10));
There is an edge from a to c in D1 and no edge from
b to d in D2.
-
+
+
+ is a synonym for
+ .
HomomorphicProduct(PetersenGraph(),
@@ -2476,6 +2496,7 @@ gap> OutNeighbours(D1);
<#GAPDoc Label="LexicographicProduct">
+
A digraph.
If D1 and D2 are digraphs without multiple edges,
@@ -2495,7 +2516,10 @@ gap> OutNeighbours(D1);
The vertices a and c of D1 are equal and there is
an edge from b to d in D2.
-
+
+
+ is a synonym for
+ .
LexicographicProduct(DigraphSymmetricClosure(CycleDigraph(3)),
diff --git a/doc/prop.xml b/doc/prop.xml
index 5c293f4a3..0eea03180 100644
--- a/doc/prop.xml
+++ b/doc/prop.xml
@@ -1665,11 +1665,14 @@ false]]>
<#GAPDoc Label="Is2EdgeTransitive">
+
true or false.
If digraph is a digraph without multiple edges, then Is2EdgeTransitive
returns true if digraph is 2-edge transitive, and false
- otherwise. If digraph has multiple edges, then Is2EdgeTransitive returns an error.
+ otherwise. If digraph has multiple edges, then Is2EdgeTransitive returns an error.
+
+ is a synonym for .
A digraph is 2-edge transitive if its automorphism group
acts transitively on 2-edges via the action
diff --git a/doc/weights.xml b/doc/weights.xml
index cc569a088..524167181 100644
--- a/doc/weights.xml
+++ b/doc/weights.xml
@@ -23,8 +23,8 @@
lists, whereas the function EdgeWeightsMutableCopy returns a copy
of EdgeWeights which is a mutable list of mutable lists.
- The edge weights of a digraph cannot be computed and must be set either
- using SetEdgeWeights or .
+ The edge weights of a digraph are set upon construction with
+ .
gr := EdgeWeightedDigraph([[2], [3], [1]], [[5], [10], [15]]);
@@ -47,15 +47,21 @@ Error, List Assignment: must be a mutable list
<#GAPDoc Label="EdgeWeightedDigraph">
-
+
A digraph or fail
- The argument digraph may be a digraph or a list of lists of integers, floats or rationals.
+ This function returns an immutable digraph with edge weights set to
+ weights.
- weights must be a list of lists of integers, floats or rationals
- of an equal size and shape to OutNeighbours(digraph), otherwise it will fail.
+ If the argument digraph is a mutable digraph, then it is also
+ modified in place.
+
+ If the argument digraph is a list of lists of positive integers,
+ these are interpreted as out-neighbours for a digraph.
- This will create a digraph and set the EdgeWeights to weights.
+ The argument weights must be a list of lists of integers, floats
+ or rationals, of an equal size and shape to
+ OutNeighbours(digraph).
See .
EdgeWeights(g);
<#/GAPDoc>
+<#GAPDoc Label="UnitEdgeWeightedDigraph">
+
+
+ A digraph
+
+ This function returns an immutable digraph with all edge weights
+ set to 1. If digraph is a mutable digraph,
+ then it is also modified in place.
+ See .
+ D := Digraph([[2], [1, 3], [1]]);
+
+gap> D1 := UnitEdgeWeightedDigraph(D);
+
+gap> EdgeWeights(D1);
+[ [ 1 ], [ 1, 1 ], [ 1 ] ]
+]]>
+
+
+<#/GAPDoc>
+
<#GAPDoc Label="EdgeWeightedDigraphTotalWeight">
@@ -91,6 +118,25 @@ gap> EdgeWeightedDigraphTotalWeight(D);
<#/GAPDoc>
+<#GAPDoc Label="IsNegativeEdgeWeightedDigraph">
+
+
+ A boolean.
+
+ If digraph has edge weights, then this returns true if
+ at least one edge has negative weight, and false otherwise. If
+ digraph has no edge weights, then an error is raised.
+ D := EdgeWeightedDigraph([[2], [1]], [[5], [10]]);;
+gap> IsNegativeEdgeWeightedDigraph(D);
+false
+gap> D := EdgeWeightedDigraph([[2], [1]], [[-5], [10]]);;
+gap> IsNegativeEdgeWeightedDigraph(D);
+true]]>
+
+
+<#/GAPDoc>
+
<#GAPDoc Label="EdgeWeightedDigraphMinimumSpanningTree">
@@ -260,7 +306,7 @@ fail]]>
the number of vertices of the digraph, and e is the number of
edges.
- See .
+ See .
g := EdgeWeightedDigraph([[2, 2], [3], []], [[3, 2], [1], []]);
@@ -290,7 +336,7 @@ gap> Sum(flow[1]);
This attribute is computed by using and the
max-cut min-flow theorem.
- See .
+ See .
g := EdgeWeightedDigraph([[2, 2], [3], []], [[3, 2], [1], []]);
@@ -319,7 +365,7 @@ gap> DigraphMinimumCut(g, 1, 3);
This attribute is computed by using .
- See .
+ See .
g := EdgeWeightedDigraph([[2, 2], [3], []], [[3, 2], [1], []]);
diff --git a/doc/z-chap5.xml b/doc/z-chap5.xml
index f1da97657..bf322b769 100644
--- a/doc/z-chap5.xml
+++ b/doc/z-chap5.xml
@@ -28,7 +28,9 @@
Edge Weights
<#Include Label="EdgeWeights">
<#Include Label="EdgeWeightedDigraph">
+ <#Include Label="UnitEdgeWeightedDigraph">
<#Include Label="EdgeWeightedDigraphTotalWeight">
+ <#Include Label="IsNegativeEdgeWeightedDigraph">
<#Include Label="EdgeWeightedDigraphMinimumSpanningTree">
<#Include Label="EdgeWeightedDigraphShortestPaths">
<#Include Label="EdgeWeightedDigraphShortestPath">
diff --git a/doc/z-chap6.xml b/doc/z-chap6.xml
index f9798b51c..26f5e23bc 100644
--- a/doc/z-chap6.xml
+++ b/doc/z-chap6.xml
@@ -73,6 +73,7 @@ from} $E_a$ \emph{to} $E_b$. In this case we say that $E_a$ and $E_b$ are
<#Include Label="DigraphColouring">
<#Include Label="DigraphGreedyColouring">
<#Include Label="DigraphWelshPowellOrder">
+ <#Include Label="DigraphSmallestLastOrder">
<#Include Label="ChromaticNumber">
<#Include Label="DigraphCore">
<#Include Label="LatticeDigraphEmbedding">
diff --git a/gap/grahom.gd b/gap/grahom.gd
index b18ecce70..8e970feb7 100644
--- a/gap/grahom.gd
+++ b/gap/grahom.gd
@@ -42,7 +42,7 @@ DeclareOperation("DigraphGreedyColouring", [IsDigraph, IsHomogeneousList]);
DeclareOperation("DigraphGreedyColouringNC", [IsDigraph, IsHomogeneousList]);
DeclareAttribute("DigraphWelshPowellOrder", IsDigraph);
-DeclareAttribute("DigraphSmallestLastOrder", IsDigraph); # TODO: document
+DeclareAttribute("DigraphSmallestLastOrder", IsDigraph);
DeclareOperation("IsDigraphEndomorphism", [IsDigraph, IsTransformation]);
DeclareOperation("IsDigraphHomomorphism",
diff --git a/gap/weights.gd b/gap/weights.gd
index 423950b61..42e09e754 100644
--- a/gap/weights.gd
+++ b/gap/weights.gd
@@ -10,11 +10,13 @@
# 1. Edge Weights
DeclareAttribute("EdgeWeights", IsDigraph);
-DeclareGlobalFunction("EdgeWeightedDigraph");
+DeclareOperation("EdgeWeightedDigraph", [IsDigraph, IsList]);
+
+DeclareOperation("EdgeWeightedDigraph", [IsList, IsList]);
DeclareProperty("IsNegativeEdgeWeightedDigraph", IsDigraph and HasEdgeWeights);
DeclareAttribute("EdgeWeightedDigraphTotalWeight",
IsDigraph and HasEdgeWeights);
-DeclareAttribute("UnitEdgeWeightedDigraph", IsDigraph);
+DeclareOperation("UnitEdgeWeightedDigraph", [IsDigraph]);
# 2. Edge Weight Copies
DeclareOperation("EdgeWeightsMutableCopy", [IsDigraph and HasEdgeWeights]);
diff --git a/gap/weights.gi b/gap/weights.gi
index dc1081fcf..aff8411e5 100644
--- a/gap/weights.gi
+++ b/gap/weights.gi
@@ -12,19 +12,15 @@
# 1. Edge Weights
#############################################################################
-InstallGlobalFunction(EdgeWeightedDigraph,
+InstallMethod(EdgeWeightedDigraph,
+"for a mutable digraph and a list",
+[IsDigraph and IsMutableDigraph, IsList],
function(D, weights)
local outNeighbours, outNeighbourWeights, u, i;
- if IsDigraph(D) then
- D := DigraphCopy(D);
- else
- D := Digraph(D);
- fi;
-
# check all elements of weights is a list
- if not ForAll(weights, IsListOrCollection) then
- ErrorNoReturn("the 2nd argument (list) must be a list of lists,");
+ if not ForAll(weights, IsList) then
+ ErrorNoReturn("the 2nd argument must be a list of lists");
fi;
# check number there is an edge weight list for vertex u
@@ -54,10 +50,23 @@ function(D, weights)
od;
od;
+ MakeImmutable(D);
SetEdgeWeights(D, weights);
return D;
end);
+InstallMethod(EdgeWeightedDigraph,
+"for an immutable digraph and a list",
+[IsDigraph and IsImmutableDigraph, IsList],
+{D, weights} -> EdgeWeightedDigraph(DigraphMutableCopy(D), weights));
+
+InstallMethod(EdgeWeightedDigraph,
+"for a list and a list",
+[IsList, IsList],
+{outneighbours, weights} -> EdgeWeightedDigraph(Digraph(IsMutableDigraph,
+ outneighbours),
+ weights));
+
InstallMethod(IsNegativeEdgeWeightedDigraph, "for a digraph with edge weights",
[IsDigraph and HasEdgeWeights],
function(D)
diff --git a/tst/standard/weights.tst b/tst/standard/weights.tst
index 036dac4d0..17773c267 100644
--- a/tst/standard/weights.tst
+++ b/tst/standard/weights.tst
@@ -28,6 +28,13 @@ gap> d := EdgeWeightedDigraph(Digraph([[2], []]), [[5], []]);
gap> EdgeWeightedDigraphTotalWeight(d);
5
+# mutable converted to immutable
+gap> d := Digraph(IsMutableDigraph, [[2], []]);
+
+gap> EdgeWeightedDigraph(d, [[5], []]);;
+gap> d;
+
+
# weight not valid
gap> d := EdgeWeightedDigraph([[2], []], [["a"], []]);
Error, out-neighbour weights must be integers, floats, or rationals,
@@ -39,7 +46,7 @@ ceeding the length of the argument,
# check all elements of weights are list
gap> d := EdgeWeightedDigraph([[1], []], [5, []]);
-Error, the 2nd argument (list) must be a list of lists,
+Error, the 2nd argument must be a list of lists
# string for digraphs
gap> d := EdgeWeightedDigraph([["a"], []], [[2], []]);
@@ -65,6 +72,28 @@ gap> d := EdgeWeightedDigraph([[2], []], [[5, 10], []]);
Error, the number of out-neighbours and weights for the vertex 1 must be equal\
,
+# UnitEdgeWeightedDigraph
+gap> D := UnitEdgeWeightedDigraph(Digraph([[2], [1, 3], [1]]));
+
+gap> EdgeWeights(D);
+[ [ 1 ], [ 1, 1 ], [ 1 ] ]
+gap> D := UnitEdgeWeightedDigraph(Digraph([[3, 4], [1, 3, 4], [2, 4], [1, 2, 3]]));
+
+gap> EdgeWeights(D);
+[ [ 1, 1 ], [ 1, 1, 1 ], [ 1, 1 ], [ 1, 1, 1 ] ]
+gap> D := UnitEdgeWeightedDigraph(EmptyDigraph(4));
+
+gap> EdgeWeights(D);
+[ [ ], [ ], [ ], [ ] ]
+gap> D := UnitEdgeWeightedDigraph(EdgeWeightedDigraph([[2], []], [[5], []]));
+
+gap> EdgeWeights(D);
+[ [ 1 ], [ ] ]
+gap> D := Digraph(IsMutable, [[2], [1, 3], [1]]);;
+gap> UnitEdgeWeightedDigraph(D);;
+gap> D;
+
+
#############################################################################
# 2. Copies of edge weights
#############################################################################
diff --git a/tst/testinstall.tst b/tst/testinstall.tst
index 7ee79de9f..25b0463bd 100644
--- a/tst/testinstall.tst
+++ b/tst/testinstall.tst
@@ -541,24 +541,6 @@ gap> AutomorphismGroup(D)
> = Group([(1, 2, 3), (1, 2), (4, 5, 6), (4, 5), (1, 4)(2, 5)(3, 6)]);
true
-# UnitEdgeWeightedDigraph
-gap> D := UnitEdgeWeightedDigraph(Digraph([[2], [1, 3], [1]]));
-
-gap> EdgeWeights(D);
-[ [ 1 ], [ 1, 1 ], [ 1 ] ]
-gap> D := UnitEdgeWeightedDigraph(Digraph([[3, 4], [1, 3, 4], [2, 4], [1, 2, 3]]));
-
-gap> EdgeWeights(D);
-[ [ 1, 1 ], [ 1, 1, 1 ], [ 1, 1 ], [ 1, 1, 1 ] ]
-gap> D := UnitEdgeWeightedDigraph(EmptyDigraph(4));
-
-gap> EdgeWeights(D);
-[ [ ], [ ], [ ], [ ] ]
-gap> D := UnitEdgeWeightedDigraph(EdgeWeightedDigraph([[2], []], [[5], []]));
-
-gap> EdgeWeights(D);
-[ [ 1 ], [ ] ]
-
# SwapDigraphs
gap> C := Digraph(IsMutableDigraph, [[4], [5], [1, 2], [], []]);;
gap> D := Digraph(IsMutableDigraph, [[2, 3, 4], [1, 3, 4, 5], [1, 2], [5], [4]]);;