-
Notifications
You must be signed in to change notification settings - Fork 58
Digraph distance attributes #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
if not IsDigraph(G) then | ||
Error("Input must be a digraph"); | ||
elif not IsStronglyConnectedDigraph(G) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error("Input digraph is not strongly connected; property undefined"); | |
ErrorNoReturn("the argument <G> (a digraph) must be strongly connected"); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for v in [1 .. DigraphNrVertices(G)] do | |
for v in DigraphVertices(G) do |
|
||
InstallMethod(DigraphDistanceMetrics, "for a digraph", | ||
[IsDigraph], | ||
function(G) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
This PR is also missing any documentation at all, which makes it not mergeable at the moment. |
There was a problem hiding this 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.
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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.
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
.