From 428c5633ae5624e09f132d8bf1519fc0816aebd9 Mon Sep 17 00:00:00 2001 From: Cora Aked Date: Mon, 1 Dec 2025 12:42:27 +0000 Subject: [PATCH 1/4] Add unitedgeweight digraph --- gap/weights.gd | 1 + gap/weights.gi | 9 +++++++++ tst/testinstall.tst | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/gap/weights.gd b/gap/weights.gd index 7d11bf5f7..64dc355f5 100644 --- a/gap/weights.gd +++ b/gap/weights.gd @@ -14,6 +14,7 @@ DeclareGlobalFunction("EdgeWeightedDigraph"); DeclareProperty("IsNegativeEdgeWeightedDigraph", IsDigraph and HasEdgeWeights); DeclareAttribute("EdgeWeightedDigraphTotalWeight", IsDigraph and HasEdgeWeights); +DeclareAttribute("UnitEdgeWeightedDigraph", IsDigraph); # 2. Edge Weight Copies DeclareOperation("EdgeWeightsMutableCopy", [IsDigraph and HasEdgeWeights]); diff --git a/gap/weights.gi b/gap/weights.gi index 5b246b002..b7e55bf19 100644 --- a/gap/weights.gi +++ b/gap/weights.gi @@ -79,6 +79,15 @@ InstallMethod(EdgeWeightedDigraphTotalWeight, [IsDigraph and HasEdgeWeights], D -> Sum(EdgeWeights(D), Sum)); +InstallMethod(UnitEdgeWeightedDigraph, +"for a digraph", +[IsDigraph], +function(D) + local x, unitweights; + unitweights := List(DigraphVertices(D), x -> ListWithIdenticalEntries(OutDegreeOfVertex(D, x), 1)); + return(EdgeWeightedDigraph(D, unitweights)); +end); + ############################################################################# # 2. Copies of edge weights ############################################################################# diff --git a/tst/testinstall.tst b/tst/testinstall.tst index 291b09b7a..7ead5b92e 100644 --- a/tst/testinstall.tst +++ b/tst/testinstall.tst @@ -541,6 +541,24 @@ 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]]);; From 7d46ad5b9bee9827229feac08e3416bb033cfa1c Mon Sep 17 00:00:00 2001 From: Cora Aked Date: Mon, 1 Dec 2025 13:26:40 +0000 Subject: [PATCH 2/4] Add 'edge-weighted' output to tests --- tst/testinstall.tst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tst/testinstall.tst b/tst/testinstall.tst index 7ead5b92e..f1b8bcca5 100644 --- a/tst/testinstall.tst +++ b/tst/testinstall.tst @@ -543,19 +543,19 @@ 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 ], [ ] ] From be9fc3c1ba89ce950159b4aea153427d312deae4 Mon Sep 17 00:00:00 2001 From: Cora Aked Date: Wed, 3 Dec 2025 16:50:52 +0000 Subject: [PATCH 3/4] gaplint checks implemented --- gap/weights.gi | 6 +++--- tst/testinstall.tst | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gap/weights.gi b/gap/weights.gi index b7e55bf19..2ffca63d6 100644 --- a/gap/weights.gi +++ b/gap/weights.gi @@ -79,12 +79,12 @@ InstallMethod(EdgeWeightedDigraphTotalWeight, [IsDigraph and HasEdgeWeights], D -> Sum(EdgeWeights(D), Sum)); -InstallMethod(UnitEdgeWeightedDigraph, -"for a digraph", +InstallMethod(UnitEdgeWeightedDigraph, "for a digraph", [IsDigraph], function(D) local x, unitweights; - unitweights := List(DigraphVertices(D), x -> ListWithIdenticalEntries(OutDegreeOfVertex(D, x), 1)); + unitweights := List(DigraphVertices(D), x -> + ListWithIdenticalEntries(OutDegreeOfVertex(D, x), 1)); return(EdgeWeightedDigraph(D, unitweights)); end); diff --git a/tst/testinstall.tst b/tst/testinstall.tst index f1b8bcca5..fa35b32cf 100644 --- a/tst/testinstall.tst +++ b/tst/testinstall.tst @@ -542,11 +542,11 @@ gap> AutomorphismGroup(D) true # UnitEdgeWeightedDigraph -gap> D := UnitEdgeWeightedDigraph(Digraph([[2],[1,3],[1]])); +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> 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 ] ] From 7394b87d0597993afbb4f2c52cecf05fdb69687d Mon Sep 17 00:00:00 2001 From: Cora Aked Date: Wed, 3 Dec 2025 17:20:29 +0000 Subject: [PATCH 4/4] fix trailing whitespace at line:86 --- gap/weights.gi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gap/weights.gi b/gap/weights.gi index 2ffca63d6..dd1a6247f 100644 --- a/gap/weights.gi +++ b/gap/weights.gi @@ -83,7 +83,7 @@ InstallMethod(UnitEdgeWeightedDigraph, "for a digraph", [IsDigraph], function(D) local x, unitweights; - unitweights := List(DigraphVertices(D), x -> + unitweights := List(DigraphVertices(D), x -> ListWithIdenticalEntries(OutDegreeOfVertex(D, x), 1)); return(EdgeWeightedDigraph(D, unitweights)); end);