Skip to content

Implementation of DigraphInsertEdge and DigraphReduceEdge#899

Open
linuskuehnle wants to merge 4 commits intodigraphs:mainfrom
linuskuehnle:main
Open

Implementation of DigraphInsertEdge and DigraphReduceEdge#899
linuskuehnle wants to merge 4 commits intodigraphs:mainfrom
linuskuehnle:main

Conversation

@linuskuehnle
Copy link
Copy Markdown

Implemented DigraphInsertEdge and DigraphReduceEdge.
These functions already exist in the Simplicial Surfaces package, which I am currently working on with Meike Weiß at RWTH Aachen University.
For reference, the corresponding functions there are implemented as EdgeInsertion and EdgeReduction.

Both DigraphInsertEdge and DigraphReduceEdge check whether the given digraph D is symmetric, and modifications to D preserve this symmetry.
Should D therefore retain the symmetric tag by explicitly calling SetIsSymmetricDigraph after modification?
If so, is an additional call to SetDigraphSymmetricClosureAttr required?

@james-d-mitchell
Copy link
Copy Markdown
Member

Thanks for the contribution @linuskuehnle ! I'll try to review your PR and answer your questions early next week.

Copy link
Copy Markdown
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.

Generally this looks pretty good, thanks for the contribution @linuskuehnle ! If you could please address the comments, then I'll be happy to merge this.

Comment thread doc/oper.xml
then then this operation inserts a new edge between <A>edge1</A> and
<A>edge2</A>.
<A>edge1</A> and <A>edge2</A> are split up into two new edges each, which are
all adjacent to the inserted edge. Hence, the vertices of the inserted edge both
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does it mean for an edge to be adjacent to an edge?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

By adjacent edges I mean edges that share a common vertex. The operation subdivides edge1 and edge2 by placing a new vertex on each, and then connects those two new vertices with a newly inserted edge. So the four 'split' edge halves share endpoints with the newly inserted edge. Hope i explained it properly now.
Should i rephrase the documentation here?

Comment thread doc/oper.xml Outdated
<Returns>A digraph.</Returns>
<Description>
If <A>edge1</A> and <A>edge2</A> are distinct pairs of vertices of <A>digraph</A>,
then then this operation inserts a new edge between <A>edge1</A> and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
then then this operation inserts a new edge between <A>edge1</A> and
then this operation inserts a new edge between <A>edge1</A> and

Comment thread doc/oper.xml Outdated
<A>edge2</A>.
<A>edge1</A> and <A>edge2</A> are split up into two new edges each, which are
all adjacent to the inserted edge. Hence, the vertices of the inserted edge both
have a degree of 3.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
have a degree of 3.
have a degree of 3.<P/>

Comment thread doc/oper.xml Outdated
all adjacent to the inserted edge. Hence, the vertices of the inserted edge both
have a degree of 3.

The opposite operation is <Ref Oper="DigraphReduceEdge"/>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The opposite operation is <Ref Oper="DigraphReduceEdge"/>.
The opposite operation is <Ref Oper="DigraphReduceEdge"/>.<P/>

Comment thread doc/oper.xml
A new digraph constructed from <A>digraph</A> is returned,
unless <A>digraph</A> belongs to <Ref Filt="IsMutableDigraph"/>;
in this case changes are made directly to <A>digraph</A>, which is then returned.
The <A>digraph</A> must not belong to <Ref Filt="IsMultiDigraph"/>. <P/>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe say that an error is thrown if IsMultiDigraph is true?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I copied this section from the documentation of DigraphContractEdge. I can mention that an error is thrown in that case, should i then adjust it for DigraphContractEdge as well?

Comment thread gap/oper.gi Outdated

DIGRAPHS_CheckInsertEdgeDigraph(D, edge1, edge2);

numVertices := Maximum(DigraphVertices(D));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
numVertices := Maximum(DigraphVertices(D));
numVertices := DigraphNrVertices(D);

Comment thread gap/oper.gi Outdated
return MakeImmutable(D);
end);

DIGRAPHS_CheckReduceEdgeDigraph := function(D, edge)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same two comments for this function:

  1. It doesn't need to exist;
  2. it can be shortened a little by combining multiple if statements with elif

Comment thread gap/oper.gi Outdated
function(D, edge1, edge2)
D := DigraphInsertEdge(DigraphMutableCopy(D), edge1, edge2);

return MakeImmutable(D);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return MakeImmutable(D);
{D, edge1, edge2} -> MakeImmutable(DigraphInsertEdge(DigraphMutableCopy(D), edge1, edge2)));

Comment thread gap/oper.gi Outdated

leftVertexOutNeighbours := OutNeighboursOfVertex(D, edge[1]);
rightVertexOutNeighbours := OutNeighboursOfVertex(D, edge[2]);
allVertexOutNeighbours := Union(leftVertexOutNeighbours,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd move this down after the checks in 713, to avoid computing this in case an error is already given.

Comment thread gap/oper.gi Outdated
InstallMethod(DigraphReduceEdge,
"for a symmetric digraph and a dense list",
[IsImmutableDigraph, IsDenseList],
function(D, edge)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
function(D, edge)
{D, edge} -> MakeImmutable(DigraphReduceEdge(DigraphMutableCopy(D), edge)));

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.

2 participants