Skip to content

Conversation

weremczuk
Copy link

@weremczuk weremczuk commented May 7, 2025

Following my comparison of features in Sage vs. GAP, I added functions computing the radius, periphery, and centre of a strongly connected digraph (DigraphRadius, DigraphPeriphery, DigraphCentre).

Could be merged with DiagraphDiameter.

@weremczuk weremczuk marked this pull request as ready for review May 21, 2025 21:32
Comment on lines +3439 to +3441
if not IsDigraph(G) then
Error("Input must be a digraph");
elif not IsStronglyConnectedDigraph(G) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not IsDigraph(G) then
Error("Input must be a digraph");
elif not IsStronglyConnectedDigraph(G) then
if not IsStronglyConnectedDigraph(G) then

The first if clause is redundant.

if not IsDigraph(G) then
Error("Input must be a digraph");
elif not IsStronglyConnectedDigraph(G) then
Error("Input digraph is not strongly connected; property undefined");
Copy link
Member

@james-d-mitchell james-d-mitchell Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error("Input digraph is not strongly connected; property undefined");
ErrorNoReturn("the argument <G> (a digraph) must be strongly connected");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please make a similar change for the error message a few lines above.

Error("Input digraph is not strongly connected; property undefined");
fi;
ecc := [];
for u in [1 .. DigraphNrVertices(G)] do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for u in [1 .. DigraphNrVertices(G)] do
for u in DigraphVertices(G) do

ecc := [];
for u in [1 .. DigraphNrVertices(G)] do
c := 0;
for v in [1 .. DigraphNrVertices(G)] do
Copy link
Member

@james-d-mitchell james-d-mitchell Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for v in [1 .. DigraphNrVertices(G)] do
for v in DigraphVertices(G) do


InstallMethod(DigraphDistanceMetrics, "for a digraph",
[IsDigraph],
function(G)
Copy link
Member

@james-d-mitchell james-d-mitchell Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think G should be changed to D everywhere here, for consistency.

od;
Add(ecc, c);
od;
return rec(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure but I think the following is not particularly efficient because the computation of Minimum(ecc) and Maximum(ecc) will be repeated for each distinct value of i which is not such a good idea. Better to compute these values prior to this return statement.

@james-d-mitchell
Copy link
Member

This PR is also missing any documentation at all, which makes it not mergeable at the moment.

Copy link
Member

@james-d-mitchell james-d-mitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires some changes before this can be merged.

Copy link
Collaborator

@wilfwilson wilfwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution! I second James's comments, and also please include some more extensive tests beyond just cycle digraphs.

if not IsDigraph(G) then
Error("Input must be a digraph");
elif not IsStronglyConnectedDigraph(G) then
Error("Input digraph is not strongly connected; property undefined");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please make a similar change for the error message a few lines above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants