I try to compute the Automorphisms of graphs with multiple edges from its AdjacencyMatrix but failed. The following code shows how to compute the Automorphisms of graphs without multiple edges:
Block[{$ContextPath}, Needs["Combinatorica`"];
Needs["GraphUtilities`"]]
m = ({
{0, 1, 1, 1},
{1, 0, 1, 1},
{1, 1, 0, 1},
{1, 1, 1, 0}
});
g = AdjacencyGraph[m];
Combinatorica`Automorphisms@GraphUtilities`ToCombinatoricaGraph[g]//Lenght (*24*)
As I have tried, AdjacencyGraph, IncidenceGraph will fail to convert a matrix into a graph. And
Graph[{1 \[UndirectedEdge] 2, 1 \[UndirectedEdge] 2}]
will fail also. But if I plot the graph as a figure directly Automorphisms will fail at that figure of graph. Other software will do this work, for example Sage.
So, how to compute the Automorphisms of graphs with multiple edges in Mathematica?
Answer
I hope the following is helpful:
Firstly, consider this example:
gr = System`Graph[{1 <-> 2, 2 <-> 3, 3 <-> 4, 3 <-> 5}];
sysm = System`AdjacencyMatrix[gr];
com = Combinatorica`FromAdjacencyMatrix[Normal@sysm];
aut = Combinatorica`Automorphisms[com];
ex = System`Graph[EdgeList[gr],
VertexLabels -> Table[j -> Placed[#[[j]], Center], {j, 5}],
VertexSize -> 0.4, VertexLabelStyle -> Directive[20, White]] & /@
aut

Automating (this is not pretty but a start):
fun[mat_] := Module[{sg, sgel, cg, au},
Needs["Combinatorica`"];
sg = System`AdjacencyGraph[mat];
sgel = EdgeList[sg];
cg = Combinatorica`FromAdjacencyMatrix[mat];
au = Combinatorica`Automorphisms[cg];
System`Graph[sgel,
VertexLabels ->
Table[j -> Placed[#[[j]], Center], {j, VertexCount@sg}],
VertexSize -> 0.4, VertexLabelStyle -> Directive[12, White]] & /@
au]
Applying to your complete graph (which necessarily has 4!=24 automorphisms) and visualizing:
m = ({{0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}});
gg = GraphicsGrid[Partition[fun[m], 6], Frame -> All,
ImageSize -> 500]

Comments
Post a Comment