Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Does Sage keep the order of vertices in a graph and it's group or scramble them? For me it sometime scrambles them.

I use the Sage automorphism_group function to find the group that leaves an adjacency matric, say C, invariant under a similarity transformation. But sometimes it seems the results are for matrices on a vertex space that is not the same as the original, but is reordered.

A simple example on a 3-vertex graph: o--o--o.

with index order               1  0  2

Adjacency matrix= C =

 [0 1 1]
 [1 0 0]
 [1 0 0]

The group is the identity and a reflection about the center vertex:

[1 0 0]       [0 1 0]
[0 1 0]  and  [1 0 0] = R
[0 0 1]       [0 0 1]

I would have expected the reflection to be,

[1 0 0]
[0 0 1]
[0 1 0],

but R is what Sage gives.

Sure enough, RCR^-1 gives the following,

[0 1 0]
[1 0 1]
[0 1 0]

which is not the original C matrix. However the R transformation leaves the matrix

[0 0 1]
[0 0 1] = C'
[1 1 0]

invariant. The last matrix is the C matrix where the vertices are indexed in reverse order.

Does Sage have some canonical way it orders the vertices in graphs and groups?

A bit more info, maybe. The order of the irreducible representation table seems to give a hint. If the trivial representation is the first row (which it is for some graphs), it appears (from a few tests) that the vertices retain their original order to align with C. If the trivial representation is the last row then the matrix C' is the adjacency matrix (suggesting a reordering of the vertices). I have no idea why this should be related if it is.

Bottom line for me is I cannot apply any matrices from the group that come from the matrix() method to C or other objects in my original vertex space since they are ordered differently. I don't see how to find the vertex order sage uses. Any help or insight appreciated.