Implementation of DigraphInsertEdge and DigraphReduceEdge#899
Implementation of DigraphInsertEdge and DigraphReduceEdge#899linuskuehnle wants to merge 3 commits intodigraphs:mainfrom
Conversation
…InsertEdge and DigraphReduceEdge
|
Thanks for the contribution @linuskuehnle ! I'll try to review your PR and answer your questions early next week. |
… edge's vertices having two common neighbours
james-d-mitchell
left a comment
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
What does it mean for an edge to be adjacent to an edge?
| <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 |
There was a problem hiding this comment.
| 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 |
| <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. |
There was a problem hiding this comment.
| have a degree of 3. | |
| have a degree of 3.<P/> |
| 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"/>. |
There was a problem hiding this comment.
| The opposite operation is <Ref Oper="DigraphReduceEdge"/>. | |
| The opposite operation is <Ref Oper="DigraphReduceEdge"/>.<P/> |
| 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/> |
There was a problem hiding this comment.
Maybe say that an error is thrown if IsMultiDigraph is true?
|
|
||
| DIGRAPHS_CheckInsertEdgeDigraph(D, edge1, edge2); | ||
|
|
||
| numVertices := Maximum(DigraphVertices(D)); |
There was a problem hiding this comment.
| numVertices := Maximum(DigraphVertices(D)); | |
| numVertices := DigraphNrVertices(D); |
| return MakeImmutable(D); | ||
| end); | ||
|
|
||
| DIGRAPHS_CheckReduceEdgeDigraph := function(D, edge) |
There was a problem hiding this comment.
Same two comments for this function:
- It doesn't need to exist;
- it can be shortened a little by combining multiple
ifstatements withelif
| function(D, edge1, edge2) | ||
| D := DigraphInsertEdge(DigraphMutableCopy(D), edge1, edge2); | ||
|
|
||
| return MakeImmutable(D); |
There was a problem hiding this comment.
| return MakeImmutable(D); | |
| {D, edge1, edge2} -> MakeImmutable(DigraphInsertEdge(DigraphMutableCopy(D), edge1, edge2))); |
|
|
||
| leftVertexOutNeighbours := OutNeighboursOfVertex(D, edge[1]); | ||
| rightVertexOutNeighbours := OutNeighboursOfVertex(D, edge[2]); | ||
| allVertexOutNeighbours := Union(leftVertexOutNeighbours, |
There was a problem hiding this comment.
I'd move this down after the checks in 713, to avoid computing this in case an error is already given.
| InstallMethod(DigraphReduceEdge, | ||
| "for a symmetric digraph and a dense list", | ||
| [IsImmutableDigraph, IsDenseList], | ||
| function(D, edge) |
There was a problem hiding this comment.
| function(D, edge) | |
| {D, edge} -> MakeImmutable(DigraphReduceEdge(DigraphMutableCopy(D), edge))); |
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?