From 232c3d5cbb3e91c9e03394fb3521e4f47661cc51 Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Tue, 6 Oct 2026 22:31:11 +0100 Subject: [PATCH 1/7] Add distance metrics for strongly directed graphs, including radius, centre, and periphery --- gap/attr.gd | 4 ++++ gap/attr.gi | 33 +++++++++++++++++++++++++++++++++ tst/standard/attr.tst | 18 ++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/gap/attr.gd b/gap/attr.gd index 09d171f6a..e151c7fdf 100644 --- a/gap/attr.gd +++ b/gap/attr.gd @@ -49,6 +49,10 @@ DeclareAttribute("DigraphDegeneracyOrdering", IsDigraph); DeclareAttribute("DIGRAPHS_Degeneracy", IsDigraph); DeclareAttribute("DigraphShortestDistances", IsDigraph); DeclareAttribute("DigraphDiameter", IsDigraph); +DeclareAttribute("DigraphDistanceMetrics", IsDigraph); +DeclareAttribute("DigraphRadius", IsDigraph); +DeclareAttribute("DigraphCentre", IsDigraph); +DeclareAttribute("DigraphPeriphery", IsDigraph); DeclareAttribute("DigraphGirth", IsDigraph); DeclareAttribute("DigraphOddGirth", IsDigraph); DeclareAttribute("DigraphUndirectedGirth", IsDigraph); diff --git a/gap/attr.gi b/gap/attr.gi index ebaf86487..5ec9755da 100644 --- a/gap/attr.gi +++ b/gap/attr.gi @@ -1508,6 +1508,38 @@ function(D) return DIGRAPH_DIAMETER(D); end); +InstallMethod(DigraphDistanceMetrics, "for a digraph", +[IsDigraph], +function(D) + local eccentricities, minecc, maxecc; + if not IsStronglyConnectedDigraph(D) then + ErrorNoReturn("the argument (a digraph) must be strongly connected,"); + fi; + if DigraphNrVertices(D) = 0 then + ErrorNoReturn("the argument (a digraph) must have at least one ", + "vertex,"); + fi; + eccentricities := List(DigraphShortestDistances(D), Maximum); + minecc := Minimum(eccentricities); + maxecc := Maximum(eccentricities); + return rec( + DigraphRadius := minecc, + DigraphCentre := Positions(eccentricities, minecc), + DigraphPeriphery := Positions(eccentricities, maxecc)); +end); + +InstallMethod(DigraphRadius, "for a digraph", +[IsDigraph], +D -> DigraphDistanceMetrics(D).DigraphRadius); + +InstallMethod(DigraphCentre, "for a digraph", +[IsDigraph], +D -> DigraphDistanceMetrics(D).DigraphCentre); + +InstallMethod(DigraphPeriphery, "for a digraph", +[IsDigraph], +D -> DigraphDistanceMetrics(D).DigraphPeriphery); + InstallMethod(DigraphUndirectedGirth, "for a digraph", [IsDigraph], function(D) # This is only defined on undirected graphs (i.e. symmetric digraphs) @@ -3581,3 +3613,4 @@ D -> DIGRAPHS_IsJoinSemilatticeAndJoinTable(D)[2]); InstallMethod(DigraphMeetTable, "for a digraph", [IsDigraph], D -> DIGRAPHS_IsMeetSemilatticeAndMeetTable(D)[2]); + diff --git a/tst/standard/attr.tst b/tst/standard/attr.tst index 6105bfae1..aa43de87a 100644 --- a/tst/standard/attr.tst +++ b/tst/standard/attr.tst @@ -3389,6 +3389,24 @@ true gap> B[14, 15] = z; true +# DigraphDistanceMetrics +gap> DigraphDistanceMetrics(ChainDigraph(3)); +Error, the argument (a digraph) must be strongly connected, +gap> DigraphDistanceMetrics(EmptyDigraph(0)); +Error, the argument (a digraph) must have at least one vertex, +gap> DigraphRadius(CycleDigraph(5)); +4 +gap> D := Digraph([[2], [1, 3], [2, 4], [3]]);; +gap> DigraphRadius(D); +2 +gap> DigraphCentre(D); +[ 2, 3 ] +gap> DigraphPeriphery(D); +[ 1, 4 ] +gap> D := Digraph([[1, 1]]);; +gap> DigraphRadius(D); +0 + # DigraphAbsorptionProbabilities gap> gr := Digraph([[2, 3, 4], [3], [2], []]); From 5c1e47eb0b6963b630dbb9c12f6dd457587a0f8b Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Tue, 6 Oct 2026 22:31:48 +0100 Subject: [PATCH 2/7] Add documentation --- doc/attr.xml | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/z-chap4.xml | 3 +++ 2 files changed, 70 insertions(+) diff --git a/doc/attr.xml b/doc/attr.xml index c2cba764d..8031e7f70 100644 --- a/doc/attr.xml +++ b/doc/attr.xml @@ -979,6 +979,73 @@ gap> DigraphDiameter(D); <#/GAPDoc> +<#GAPDoc Label="DigraphRadius"> + + + A non-negative integer. + + The radius of a strongly connected digraph is the minimum + eccentricity over all of its vertices. The eccentricity of a vertex is the + greatest distance from it to any other vertex. +

+ If digraph is not strongly connected, or contains no vertices, then + an error is raised. + D := CycleDigraph(5);; +gap> DigraphRadius(D); +4 +gap> D := CompleteDigraph(5);; +gap> DigraphRadius(D); +1 +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="DigraphCentre"> + + + A list of vertices. + + The centre of a strongly connected digraph is the set of vertices + whose eccentricity equals the radius (see ). + The result is returned as a sorted list. +

+ If digraph is not strongly connected, or contains no vertices, then + an error is raised. + D := Digraph([[2], [1, 3], [2, 4], [3]]);; +gap> DigraphRadius(D); +2 +gap> DigraphCentre(D); +[ 2, 3 ] +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="DigraphPeriphery"> + + + A list of vertices. + + The periphery of a strongly connected digraph is the set of vertices + whose eccentricity equals the diameter (see ). + The result is returned as a sorted list. +

+ If digraph is not strongly connected, or contains no vertices, then + an error is raised. + D := Digraph([[2], [1, 3], [2, 4], [3]]);; +gap> DigraphDiameter(D); +3 +gap> DigraphPeriphery(D); +[ 1, 4 ] +]]> + + +<#/GAPDoc> + <#GAPDoc Label="DigraphGirth"> diff --git a/doc/z-chap4.xml b/doc/z-chap4.xml index 059e10eea..d62414309 100644 --- a/doc/z-chap4.xml +++ b/doc/z-chap4.xml @@ -48,6 +48,9 @@

Reachability and connectivity <#Include Label="DigraphDiameter"> + <#Include Label="DigraphRadius"> + <#Include Label="DigraphCentre"> + <#Include Label="DigraphPeriphery"> <#Include Label="DigraphShortestDistance"> <#Include Label="DigraphShortestDistances"> <#Include Label="DigraphLongestDistanceFromVertex"> From 3e1718f91dc4902a464afee178b951470b6f013a Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Thu, 8 Oct 2026 16:04:07 +0100 Subject: [PATCH 3/7] Hide method from user, change convention for bad input, add american synonym --- doc/attr.xml | 4 +++- gap/attr.gd | 3 ++- gap/attr.gi | 19 +++++++++---------- tst/standard/attr.tst | 19 ++++++++++--------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/doc/attr.xml b/doc/attr.xml index 8031e7f70..ba4fe8b1d 100644 --- a/doc/attr.xml +++ b/doc/attr.xml @@ -1005,11 +1005,13 @@ gap> DigraphRadius(D); <#GAPDoc Label="DigraphCentre"> + A list of vertices. The centre of a strongly connected digraph is the set of vertices whose eccentricity equals the radius (see ). - The result is returned as a sorted list. + The result is returned as a sorted list. is a + synonym for .

If digraph is not strongly connected, or contains no vertices, then an error is raised. diff --git a/gap/attr.gd b/gap/attr.gd index e151c7fdf..a4385f860 100644 --- a/gap/attr.gd +++ b/gap/attr.gd @@ -49,9 +49,10 @@ DeclareAttribute("DigraphDegeneracyOrdering", IsDigraph); DeclareAttribute("DIGRAPHS_Degeneracy", IsDigraph); DeclareAttribute("DigraphShortestDistances", IsDigraph); DeclareAttribute("DigraphDiameter", IsDigraph); -DeclareAttribute("DigraphDistanceMetrics", IsDigraph); +DeclareAttribute("DIGRAPHS_DistanceMetrics", IsDigraph); DeclareAttribute("DigraphRadius", IsDigraph); DeclareAttribute("DigraphCentre", IsDigraph); +DeclareSynonymAttr("DigraphCenter", DigraphCentre); DeclareAttribute("DigraphPeriphery", IsDigraph); DeclareAttribute("DigraphGirth", IsDigraph); DeclareAttribute("DigraphOddGirth", IsDigraph); diff --git a/gap/attr.gi b/gap/attr.gi index 5ec9755da..34c8853fd 100644 --- a/gap/attr.gi +++ b/gap/attr.gi @@ -1508,16 +1508,15 @@ function(D) return DIGRAPH_DIAMETER(D); end); -InstallMethod(DigraphDistanceMetrics, "for a digraph", +InstallMethod(DIGRAPHS_DistanceMetrics, "for a digraph", [IsDigraph], function(D) local eccentricities, minecc, maxecc; - if not IsStronglyConnectedDigraph(D) then - ErrorNoReturn("the argument (a digraph) must be strongly connected,"); - fi; - if DigraphNrVertices(D) = 0 then - ErrorNoReturn("the argument (a digraph) must have at least one ", - "vertex,"); + if not IsStronglyConnectedDigraph(D) or DigraphNrVertices(D) = 0 then + return rec( + DigraphRadius := fail, + DigraphCentre := fail, + DigraphPeriphery := fail); fi; eccentricities := List(DigraphShortestDistances(D), Maximum); minecc := Minimum(eccentricities); @@ -1530,15 +1529,15 @@ end); InstallMethod(DigraphRadius, "for a digraph", [IsDigraph], -D -> DigraphDistanceMetrics(D).DigraphRadius); +D -> DIGRAPHS_DistanceMetrics(D).DigraphRadius); InstallMethod(DigraphCentre, "for a digraph", [IsDigraph], -D -> DigraphDistanceMetrics(D).DigraphCentre); +D -> DIGRAPHS_DistanceMetrics(D).DigraphCentre); InstallMethod(DigraphPeriphery, "for a digraph", [IsDigraph], -D -> DigraphDistanceMetrics(D).DigraphPeriphery); +D -> DIGRAPHS_DistanceMetrics(D).DigraphPeriphery); InstallMethod(DigraphUndirectedGirth, "for a digraph", [IsDigraph], function(D) diff --git a/tst/standard/attr.tst b/tst/standard/attr.tst index aa43de87a..e22dbdf6a 100644 --- a/tst/standard/attr.tst +++ b/tst/standard/attr.tst @@ -3389,13 +3389,13 @@ true gap> B[14, 15] = z; true -# DigraphDistanceMetrics -gap> DigraphDistanceMetrics(ChainDigraph(3)); -Error, the argument (a digraph) must be strongly connected, -gap> DigraphDistanceMetrics(EmptyDigraph(0)); -Error, the argument (a digraph) must have at least one vertex, -gap> DigraphRadius(CycleDigraph(5)); -4 +# DigraphRadius, DigraphCentre, and DigraphPeriphery +gap> DigraphRadius(ChainDigraph(2)); +fail +gap> DigraphRadius(EmptyDigraph(0)); +fail +gap> DigraphRadius(CycleDigraph(3)); +2 gap> D := Digraph([[2], [1, 3], [2, 4], [3]]);; gap> DigraphRadius(D); 2 @@ -3403,9 +3403,10 @@ gap> DigraphCentre(D); [ 2, 3 ] gap> DigraphPeriphery(D); [ 1, 4 ] -gap> D := Digraph([[1, 1]]);; -gap> DigraphRadius(D); +gap> DigraphRadius(Digraph([[1, 1]])); 0 +gap> DigraphCenter; + # DigraphAbsorptionProbabilities gap> gr := Digraph([[2, 3, 4], [3], [2], []]); From c2596f67e51fca14b539da4fdaed4dd163ff5a36 Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:54:02 +0100 Subject: [PATCH 4/7] Refactor with new DigraphEccentricities --- gap/attr.gd | 2 +- gap/attr.gi | 39 +++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/gap/attr.gd b/gap/attr.gd index a4385f860..8e706a88c 100644 --- a/gap/attr.gd +++ b/gap/attr.gd @@ -49,7 +49,7 @@ DeclareAttribute("DigraphDegeneracyOrdering", IsDigraph); DeclareAttribute("DIGRAPHS_Degeneracy", IsDigraph); DeclareAttribute("DigraphShortestDistances", IsDigraph); DeclareAttribute("DigraphDiameter", IsDigraph); -DeclareAttribute("DIGRAPHS_DistanceMetrics", IsDigraph); +DeclareAttribute("DigraphEccentricities", IsDigraph); DeclareAttribute("DigraphRadius", IsDigraph); DeclareAttribute("DigraphCentre", IsDigraph); DeclareSynonymAttr("DigraphCenter", DigraphCentre); diff --git a/gap/attr.gi b/gap/attr.gi index 34c8853fd..348f8c740 100644 --- a/gap/attr.gi +++ b/gap/attr.gi @@ -1508,36 +1508,36 @@ function(D) return DIGRAPH_DIAMETER(D); end); -InstallMethod(DIGRAPHS_DistanceMetrics, "for a digraph", +InstallMethod(DigraphEccentricities, "for a digraph", +[IsDigraph], +D -> List(DigraphShortestDistances(D), Maximum)); + +InstallMethod(DigraphRadius, "for a digraph", [IsDigraph], function(D) - local eccentricities, minecc, maxecc; if not IsStronglyConnectedDigraph(D) or DigraphNrVertices(D) = 0 then - return rec( - DigraphRadius := fail, - DigraphCentre := fail, - DigraphPeriphery := fail); + return fail; fi; - eccentricities := List(DigraphShortestDistances(D), Maximum); - minecc := Minimum(eccentricities); - maxecc := Maximum(eccentricities); - return rec( - DigraphRadius := minecc, - DigraphCentre := Positions(eccentricities, minecc), - DigraphPeriphery := Positions(eccentricities, maxecc)); + return Minimum(DigraphEccentricities(D)); end); -InstallMethod(DigraphRadius, "for a digraph", -[IsDigraph], -D -> DIGRAPHS_DistanceMetrics(D).DigraphRadius); - InstallMethod(DigraphCentre, "for a digraph", [IsDigraph], -D -> DIGRAPHS_DistanceMetrics(D).DigraphCentre); +function(D) + if not IsStronglyConnectedDigraph(D) or DigraphNrVertices(D) = 0 then + return fail; + fi; + return Positions(DigraphEccentricities(D), DigraphRadius(D)); +end); InstallMethod(DigraphPeriphery, "for a digraph", [IsDigraph], -D -> DIGRAPHS_DistanceMetrics(D).DigraphPeriphery); +function(D) + if not IsStronglyConnectedDigraph(D) or DigraphNrVertices(D) = 0 then + return fail; + fi; + return Positions(DigraphEccentricities(D), DigraphDiameter(D)); +end); InstallMethod(DigraphUndirectedGirth, "for a digraph", [IsDigraph], function(D) @@ -3612,4 +3612,3 @@ D -> DIGRAPHS_IsJoinSemilatticeAndJoinTable(D)[2]); InstallMethod(DigraphMeetTable, "for a digraph", [IsDigraph], D -> DIGRAPHS_IsMeetSemilatticeAndMeetTable(D)[2]); - From 03bf6bb1db6c4be0f6ac080293eac11ddad17abf Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:54:50 +0100 Subject: [PATCH 5/7] Better tests --- tst/standard/attr.tst | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tst/standard/attr.tst b/tst/standard/attr.tst index e22dbdf6a..2feb8bdc7 100644 --- a/tst/standard/attr.tst +++ b/tst/standard/attr.tst @@ -3390,23 +3390,36 @@ gap> B[14, 15] = z; true # DigraphRadius, DigraphCentre, and DigraphPeriphery -gap> DigraphRadius(ChainDigraph(2)); +gap> D := ChainDigraph(2);; +gap> DigraphRadius(D); fail -gap> DigraphRadius(EmptyDigraph(0)); +gap> DigraphCentre(D); +fail +gap> DigraphPeriphery(D); +fail +gap> D := EmptyDigraph(0);; +gap> DigraphRadius(D); +fail +gap> DigraphCentre(D); +fail +gap> DigraphPeriphery(D); fail -gap> DigraphRadius(CycleDigraph(3)); -2 gap> D := Digraph([[2], [1, 3], [2, 4], [3]]);; gap> DigraphRadius(D); 2 +gap> DigraphDiameter(D); +3 gap> DigraphCentre(D); [ 2, 3 ] gap> DigraphPeriphery(D); [ 1, 4 ] -gap> DigraphRadius(Digraph([[1, 1]])); +gap> D := Digraph([[1, 1]]);; +gap> DigraphRadius(D); 0 -gap> DigraphCenter; - +gap> DigraphCentre(D) = DigraphPeriphery(D); +true +gap> DigraphCenter = DigraphCenter; +true # DigraphAbsorptionProbabilities gap> gr := Digraph([[2, 3, 4], [3], [2], []]); From ba9c0ff77ab856db5bfe408543be6a61162b71d7 Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:58:17 +0100 Subject: [PATCH 6/7] Docs --- doc/attr.xml | 88 ++++++++++++++++++++++++++++++------------------- doc/z-chap4.xml | 1 + 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/doc/attr.xml b/doc/attr.xml index ba4fe8b1d..fa9a8f05f 100644 --- a/doc/attr.xml +++ b/doc/attr.xml @@ -944,21 +944,41 @@ gap> DigraphShortestDistances(D); <#/GAPDoc> -<#GAPDoc Label="DigraphDiameter"> +<#GAPDoc Label="DigraphEccentricities"> - - An integer or fail. + + A list of non-negative integers or fail. - This function returns the diameter of the digraph digraph. -

+ This function returns a list of the eccentricities of each vertex in + digraph. The eccentricity of a vertex v is the maximum + shortest distance between v and any other vertex; see + .

- If a digraph digraph is strongly connected and has at least 1 - vertex, then the diameter is the maximum shortest distance between - any pair of distinct vertices. Otherwise then the diameter of - digraph is undefined, and this function returns the value - fail.

+ If digraph is not strongly connected, then the value fail + is returned. + DigraphEccentricities(Digraph([[2], [1, 3], [2]])); +[ 2, 1, 2 ] +gap> DigraphEccentricities(CycleDigraph(3)); +[ 2, 2, 2 ] +gap> DigraphEccentricities(ChainDigraph(2)); +fail +]]> + + +<#/GAPDoc> - See .

+<#GAPDoc Label="DigraphDiameter"> + + + A non-negative integer or fail. + + This function returns the diameter of digraph. If + digraph is strongly connected and has at least 1 vertex, then its + diameter is the maximum eccentricity over its vertices; see + . Otherwise, the diameter of + digraph is undefined, and the value fail is returned. D := Digraph([[2], [3], [4, 5], [5], [1, 2, 3, 4, 5]]); @@ -982,14 +1002,13 @@ gap> DigraphDiameter(D); <#GAPDoc Label="DigraphRadius"> - A non-negative integer. + A non-negative integer or fail. - The radius of a strongly connected digraph is the minimum - eccentricity over all of its vertices. The eccentricity of a vertex is the - greatest distance from it to any other vertex. -

- If digraph is not strongly connected, or contains no vertices, then - an error is raised. + This function returns the radius of digraph. If + digraph is strongly connected and has at least 1 vertex, then its + radius is the minimum eccentricity over its vertices; see + . Otherwise, the radius of + digraph is undefined, and the value fail is returned. D := CycleDigraph(5);; gap> DigraphRadius(D); @@ -1006,15 +1025,16 @@ gap> DigraphRadius(D); - A list of vertices. + A list of vertices or fail. - The centre of a strongly connected digraph is the set of vertices - whose eccentricity equals the radius (see ). - The result is returned as a sorted list. is a - synonym for . -

- If digraph is not strongly connected, or contains no vertices, then - an error is raised. + This function returns the centre of digraph. If digraph is + strongly connected and has at least 1 vertex, then its centre is the + set of all vertices whose eccentricities equal the radius of + digraph; see . Otherwise, the + centre of digraph is undefined, and the value fail is + returned.

+ + is a synonym for . D := Digraph([[2], [1, 3], [2, 4], [3]]);; gap> DigraphRadius(D); @@ -1029,14 +1049,14 @@ gap> DigraphCentre(D); <#GAPDoc Label="DigraphPeriphery"> - A list of vertices. - - The periphery of a strongly connected digraph is the set of vertices - whose eccentricity equals the diameter (see ). - The result is returned as a sorted list. -

- If digraph is not strongly connected, or contains no vertices, then - an error is raised. + A list of vertices or fail. + + This function returns the periphery of digraph. If + digraph is strongly connected and has at least 1 vertex, then its + periphery is the set of all vertices whose eccentricities equal the + diameter of digraph; see . + Otherwise, the periphery of digraph is undefined, and the + value fail is returned. D := Digraph([[2], [1, 3], [2, 4], [3]]);; gap> DigraphDiameter(D); diff --git a/doc/z-chap4.xml b/doc/z-chap4.xml index d62414309..c800a428e 100644 --- a/doc/z-chap4.xml +++ b/doc/z-chap4.xml @@ -47,6 +47,7 @@

Reachability and connectivity + <#Include Label="DigraphEccentricities"> <#Include Label="DigraphDiameter"> <#Include Label="DigraphRadius"> <#Include Label="DigraphCentre"> From 80f100cbde0f66bee32210214b01c9f77c183448 Mon Sep 17 00:00:00 2001 From: William-Kenyon <115789274+William-Kenyon@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:20:18 +0100 Subject: [PATCH 7/7] Eccentricity of empty digraph convention --- doc/attr.xml | 5 ++++- gap/attr.gi | 7 ++++++- tst/standard/attr.tst | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/attr.xml b/doc/attr.xml index fa9a8f05f..9017d14eb 100644 --- a/doc/attr.xml +++ b/doc/attr.xml @@ -950,7 +950,8 @@ gap> DigraphShortestDistances(D); A list of non-negative integers or fail. This function returns a list of the eccentricities of each vertex in - digraph. The eccentricity of a vertex v is the maximum + digraph. If digraph is strongly connected and has at least 1 + vertex, then the eccentricity of a vertex v is the maximum shortest distance between v and any other vertex; see .

@@ -964,6 +965,8 @@ gap> DigraphEccentricities(CycleDigraph(3)); [ 2, 2, 2 ] gap> DigraphEccentricities(ChainDigraph(2)); fail +gap> DigraphEccentricities(EmptyDigraph(0)); +fail ]]> diff --git a/gap/attr.gi b/gap/attr.gi index 348f8c740..af420ba17 100644 --- a/gap/attr.gi +++ b/gap/attr.gi @@ -1510,7 +1510,12 @@ end); InstallMethod(DigraphEccentricities, "for a digraph", [IsDigraph], -D -> List(DigraphShortestDistances(D), Maximum)); +function(D) + if not IsStronglyConnectedDigraph(D) or DigraphNrVertices(D) = 0 then + return fail; + fi; + return List(DigraphShortestDistances(D), Maximum); +end); InstallMethod(DigraphRadius, "for a digraph", [IsDigraph], diff --git a/tst/standard/attr.tst b/tst/standard/attr.tst index 2feb8bdc7..abf6cec5e 100644 --- a/tst/standard/attr.tst +++ b/tst/standard/attr.tst @@ -3389,8 +3389,10 @@ true gap> B[14, 15] = z; true -# DigraphRadius, DigraphCentre, and DigraphPeriphery +# DigraphEccentricities, DigraphRadius, DigraphCentre, and DigraphPeriphery gap> D := ChainDigraph(2);; +gap> DigraphEccentricities(D); +fail gap> DigraphRadius(D); fail gap> DigraphCentre(D); @@ -3398,6 +3400,8 @@ fail gap> DigraphPeriphery(D); fail gap> D := EmptyDigraph(0);; +gap> DigraphEccentricities(D); +fail gap> DigraphRadius(D); fail gap> DigraphCentre(D);