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

Disable edge labels if not already set in some cases #540

Merged

Conversation

james-d-mitchell
Copy link
Member

This PR is related to #500, and ensures that edge labels aren't set when taking the reflexive closure of a digraph if the original digraph doesn't have any edge labels.

@james-d-mitchell james-d-mitchell force-pushed the edge-labels-1 branch 3 times, most recently from 9edeb5b to 95d053c Compare April 6, 2022 08:21
gap/attr.gi Outdated
if not ismulti then
SetDigraphEdgeLabel(C, v, v, 1);
fi;
if not IsDigraphEdge(D, v, v) then
Copy link
Member Author

Choose a reason for hiding this comment

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

By way of explanation, we use IsDigraphEdge(D, v, v) because D might know, for example, its adjacency matrix and this is hopefully then used by IsDigraphEdge, whereas C is mutable so doesn't have any attributes.

gap/attr.gi Outdated
SetDigraphEdgeLabel(C, v, v, 1);
fi;
if not IsDigraphEdge(D, v, v) then
DigraphAddEdge(C, v, v);
Copy link
Member Author

Choose a reason for hiding this comment

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

DigraphAddEdge only sets edge labels if D already has edge labels, so we avoid the overhead described in #500, by doing this.

function(D)
local ismulti, C, list, v;
if HasIsReflexiveDigraph(D) and IsReflexiveDigraph(D) then
Copy link
Member Author

Choose a reason for hiding this comment

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

I've also removed this if-clause because it clashes with the documentation, which states that a new digraph is returned if D is immutable. Not sure if this is desirable or not

@james-d-mitchell james-d-mitchell added the enhancement A label for PRs that provide enhancements. label Apr 6, 2022
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.

Fine by me.

In general, I would prefer methods to return the identical object if nothing has changed, but I realise that that's separate topic, and the package and the documentation are inconsistent about this. So I don't mind you making that change.

@james-d-mitchell james-d-mitchell merged commit f7422d1 into digraphs:stable-1.5 Apr 6, 2022
@james-d-mitchell james-d-mitchell deleted the edge-labels-1 branch April 6, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A label for PRs that provide enhancements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants