Conversation
… and without optimisation
| Label="for a digraph"/> | ||
| <Returns>A list of lists of integers.</Returns> | ||
| <Description> | ||
| Colour Refinement is a method of colouring a digraph such that for a colour, every |
There was a problem hiding this comment.
Inappropriate capitalisation.
| <Description> | ||
| Colour Refinement is a method of colouring a digraph such that for a colour, every | ||
| node with that colouring has an identical configuration of coloured neighbours. That is, | ||
| all nodes of colour <A>q</A> have the same number of neighbours of colour <A>x</A>, and colour y</A>, etc. |
There was a problem hiding this comment.
| all nodes of colour <A>q</A> have the same number of neighbours of colour <A>x</A>, and colour y</A>, etc. | |
| all nodes of colour <A>q</A> have the same number of neighbours of colour <A>x</A>, and colour <A>y</A>, etc. |
but also this should probably say: "all nodes with the same colour have equal numbers of nodes of every colour"
| Colour Refinement is a method of colouring a digraph such that for a colour, every | ||
| node with that colouring has an identical configuration of coloured neighbours. That is, | ||
| all nodes of colour <A>q</A> have the same number of neighbours of colour <A>x</A>, and colour y</A>, etc. | ||
| <C>DigraphColourRefinement</C> considers the out neighbours and in neighbours of a node separately. |
There was a problem hiding this comment.
This should be expanded to say exactly how they are considered separately.
| all nodes of colour <A>q</A> have the same number of neighbours of colour <A>x</A>, and colour y</A>, etc. | ||
| <C>DigraphColourRefinement</C> considers the out neighbours and in neighbours of a node separately. | ||
| <P/> | ||
| This involves recolouring the digraph each iteration until it is 'refined'. It returns the colouring as a |
There was a problem hiding this comment.
What is This? What iterations are you referring to? What does 'refined' mean in this context? This is too imprecise.
| <P/> | ||
| This involves recolouring the digraph each iteration until it is 'refined'. It returns the colouring as a | ||
| list where the value at the ith position is the colour of node i. For two digraphs with different colourings, | ||
| we can be sure that they are not isomorphic. However, identical colourings for two digraphs does not necessarily |
There was a problem hiding this comment.
I'm not sure I believe this, the colouring as returned by this function depends on the order the vertices appear in the digraph, but isomorphism does not.
| j, P, v, Out, In, Sets, pair, current, currentPair, newSet, colour; | ||
|
|
||
| # Or just remove loops? | ||
| if not DigraphNrLoops(D) = 0 then |
There was a problem hiding this comment.
| if not DigraphNrLoops(D) = 0 then | |
| if DigraphHasLoops(D) then |
| C := []; | ||
| for v in DigraphVertices(D) do | ||
| C[v] := 1; | ||
| od; |
There was a problem hiding this comment.
| C := []; | |
| for v in DigraphVertices(D) do | |
| C[v] := 1; | |
| od; | |
| C := List(DigraphNrVertices(D), x -> 1); |
mtorpey
left a comment
There was a problem hiding this comment.
A few suggestions for changes here! Great work, and this stuff shouldn't take too much longer.
| largest := 1; | ||
| for j in [1 .. Length(colour_cell)] do | ||
| if Length(colour_cell[j]) > Length(colour_cell[largest]) then | ||
| largest := j; | ||
| fi; | ||
| od; |
There was a problem hiding this comment.
I think this might be replacable with largest := PositionMaximum(colour_cell, Length). Could you try this?
|
Hi @RheyaM! Well done on the quick fixes. Once you've tried that PositionMaximum fix above, it's just about resolving that "canonical" thing. If you can have a quick think about that and then leave a comment here summarising to what extent it's canonical, and what "canonical" means, I think we can merge this. |
There was a problem hiding this comment.
I've had quite a thorough look at this now, and it seems to me like the colouring that get's returned is canonical; as far as I can tell, we don't use any information of the vertex labels when deciding which cells/colours to refine with respect to. If we could mention this in the documentation (and also do what Michael suggested in his comment) then I would be happy for this to be merged.
Nice work @RheyaM!
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
| colour of node i. The time complexity of this algorithm is <M>O(n^2 log n)</M>. | ||
| <P/> | ||
| Because the labels of the vertices are not used in any capacity during the refinement process (I.e. to determine which cells | ||
| to refine), the colouring produced is canonical. This means that for two isomorphic digraphs, they would produce the same colouring. |
There was a problem hiding this comment.
Sorry to keep fussing, but one more thing that should be made clear here.
The colouring is canonical, but my understanding is that the output of the function is not canonical (because it's a list that uses the ordering of vertices). This should be made clear, because as written it sounds like isomorphic digraphs have the same output.
Have I got this right
There was a problem hiding this comment.
I added an explanation for this, but I'm not sure if it comes across clearly so I included two isomorphic digraphs in the examples and their 'identical' colourings (I just swapped vertices 1 and 8, and the output swaps the colours of those vertices as well). Is that okay/does it make sense?
| <C>DigraphColourRefinement</C> returns the colouring as a list where the value at the ith position is the | ||
| colour of node i. The time complexity of this algorithm is <M>O(n^2 log n)</M>. | ||
| <P/> | ||
| Because the labels of the vertices are not used in any capacity during the refinement process (I.e. to determine which cells |
Implementation of DigraphColourRefinement. Takes a digraph and returns a colouring (A list where value at ith position is the colour of the ith node), such that all nodes with the same colour have the same configuration of coloured neighbours. That is, if two nodes have the same colour, they will have the same number of neighbours of colour x, and colour y, etc. DigraphColourRefinement considers out and in neighbours separately.
If two digraphs produce two different colouring under Colour Refinement, we can know that they are not isomorphic.
Now includes optimisation step