Actually, I wouldn't call what IGReorderVertices
does relabelling. It really just changes the order in which vertices are stored. This in turn affects how certain functions work: the result of AdjacencyMatrix
, the order in which BetweennessCentrality
returns results, or what DirectedGraph[graph, "Acyclic"]
does. It's more about changing the practical representation of the graph than doing anything of mathematical significance.
For true relabelling, you can use VertexReplace
.
Example:
If we have
g = Graph[{1, 2, 3}, {1 <-> 2, 2 <-> 3}]
then
IGReorderVertices[{1, 3, 2}, g]
returns the equivalent of
g = Graph[{1, 3, 2}, {1 <-> 2, 2 <-> 3}]
Note that the edge list has not changed. 2
is still the "middle" vertex.
VertexReplace[g, {1 -> 1, 2 -> 3, 3 -> 2}]
return the equivalent of
g = Graph[{1, 3, 2}, {1 <-> 3, 3 <-> 2}]
Now the edge list has changed too, as 2
was renamed to 3
and 3
was renamed to 2
.
If the relabelling is an isomorphic one, then of course the edge list doesn't change (by definition), except in its ordering. Thus, in this case, either function could be used.
In[19]:= perms = GroupElements@GraphAutomorphismGroup[g]
Out[19]= {Cycles[{}], Cycles[{{1, 3}}]}
We could do
VertexReplace[g, Thread[VertexList[g] -> Permute[VertexList[g], #]]] & /@ perms
or, keeping in mind that these re-labellings are isomorphic, simply use
IGReorderVertices[Permute[VertexList[g], #], g] & /@ perms