Equitable Partition Refinement with List Invariants

So the bug with C19H14 and C10H16 formulae seems to have been due to the partition refinement not correctly labelling structures with particular arrangements of multiple bonds. The underlying problem is in the equitable partition refinement process. This is a short note about the problem.

Equitable refinement of a partition for a graph is the formation of a vertex partition where each element of each block of the partition has an equal number of neighbours in the other blocks. This is a little difficult to imagine, but it is - roughly - a generalisation of the Morgan number algorithm which attempts to find labels for sets of vertices which are stable with respect to splitting them by the labels of the neighbours.

For example:

This image shows a cub-2-ene like molecule (or a cube graph with two of the edges colored). Clearly the orange and green vertices are in 'different' sets in some sense. Precisely, they are in different blocks of the equitable partition ([0,2,5,7|1,3,4,6]) as they have different sets of bonds to neighbours.

In fact, all I have changed is to turn the invariants for the refinement procedure from numbers (the neighbour count) to lists of numbers : the ordered list of counts of neighbours connected by an edge of a particular color. This seems to work for the purpose I need it (structure generation) but it may be that it doesn't work for some more subtle use case.