Skip to content
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

Behaviour of DigraphRemoveEdge/DigraphRemoveEdges is inconsistent #260 #723

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

saffronmciver
Copy link
Contributor

  • Edited functions for DigraphRemoveEdge, DigraphRemoveEdges, DigraphReverseEdge, DigraphReverseEdges, DigraphRemoveVertices and QuotientGraph.
  • Checks added to see if any work needs to be done before making a copy.

Saffron and others added 3 commits February 5, 2025 13:24
- Edited functions for DigraphRemoveEdge, DigraphRemoveEdges,
  DigraphReverseEdge, DigraphReverseEdges, DigraphRemoveVertices and
QuotientGraph
- Checks added to see if any work needs to be done before making a copy
@saffronmciver
Copy link
Contributor Author

DigraphsTestsStandard fails due to a test expecting output where the attributes of a graph are retained after the immutable call of DigraphRemoveVertices.

@james-d-mitchell
Copy link
Member

@saffronmciver if you pull from main and then rebase your branch then hopefully the lint job will pass

@saffronmciver saffronmciver marked this pull request as ready for review February 7, 2025 11:47
gap/oper.gi Outdated
Comment on lines 170 to 171
if ForAll(list, IsPosInt) and
not (ForAny(list, x -> x <= DigraphNrVertices(D))) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the list has negative integers, then presumably the input digraph should still not be copied?

Instead of testing IsPosInt and then checking <=, would we be better to check ForAny(list, x -> not x in DigraphVertices(D)? Then it's a single clean statement that catches everything.

gap/oper.gi Outdated
Comment on lines 264 to 265
DMutable := DigraphMutableCopy(D);
DIGRAPHS_CheckDigraphRemoveEdge(DMutable, src, ran);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we create a copy and then check it is valid. Why not check the original graph before copying, so that extra work is not done?

gap/oper.gi Outdated
Comment on lines 309 to 310
# If any edges have been removed
if DigraphNrEdges(D) <> DigraphNrEdges(DMutableRemoved) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, could we somehow check this before copying, to avoid the extra work if it's not necessary?

I think you could check all the inputs with IsDigraphEdge rather than comparing numbers after a copy.

gap/oper.gi Outdated
Comment on lines 402 to 411
DMutable := DigraphMutableCopy(D);
for edge in E do
DigraphReverseEdge(DMutable, edge);
if edge[1] <> edge[2] then # The edge could be reversed
changed := true;
fi;
od;

if changed = true then
return MakeImmutable(DMutable);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, could we figure out whether the condition is true without creating a copy first?

@james-d-mitchell
Copy link
Member

james-d-mitchell commented Feb 12, 2025

I'm not sure because I haven't looked at the pr in detail but isn't this a backwards incompatible change? I.e it's not impossible that there's code in existence that relies on a copy being returned even if no changes are made? If so then we should probably not merge this into main just now, but maybe include stable-2.0 branch instead?

@mtorpey
Copy link
Collaborator

mtorpey commented Feb 13, 2025

@james-d-mitchell: that's correct. This PR even involves changing the documentation to reflect the new behaviour, so it's a breaking change.

Do we have a branch for 2.0 yet?

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

Successfully merging this pull request may close these issues.

3 participants