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..f1b8bcca5 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]]);;