-
Notifications
You must be signed in to change notification settings - Fork 46
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
Disable edge labels if not already set in some cases #540
Conversation
9edeb5b
to
95d053c
Compare
gap/attr.gi
Outdated
if not ismulti then | ||
SetDigraphEdgeLabel(C, v, v, 1); | ||
fi; | ||
if not IsDigraphEdge(D, v, v) 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.
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); |
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.
DigraphAddEdge
only sets edge labels if D
already has edge labels, so we avoid the overhead described in #500, by doing this.
95d053c
to
d504df9
Compare
function(D) | ||
local ismulti, C, list, v; | ||
if HasIsReflexiveDigraph(D) and IsReflexiveDigraph(D) 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.
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
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.
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.
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.