Why does this not change the names of the vertices?
Graph[List[1,2,3], List[UndirectedEdge[1,2], UndirectedEdge[1,3]], List[Rule[VertexLabels,List[Automatic]]]] /. {1->a,2->b,3->c}
(* the graph = allConnected[3] *)
The graph is obtained using the code here.
allEdges[n_] :=
Flatten[Table[UndirectedEdge[i, j], {i, 1, n}, {j, i + 1, n}]];
allConnected[n_] :=
Select[Map[Graph[Range[n], #, VertexLabels -> Automatic] &,
Subsets[allEdges[n]]], ConnectedGraphQ];
allConnectedUpToIso[n_] :=
DeleteDuplicates[allConnected[n], IsomorphicGraphQ];
Why does this not work? I want to change the vertice names to my customized names.
I know that I can convert the graph to edge lists and then try the rule (already tried).
I'm curious why it does not work and can we try the rule without converting them to edge lists?
Graph[List[1,2,3], List[UndirectedEdge[1,2], UndirectedEdge[1,3]], List[Rule[VertexLabels,List[Automatic]]]] /. {1->a,2->b,3->c}
not change the names of the vertices? $\endgroup$Graph
transforms to a raw object, similar to sparse arrays, see this answer. I think this question can actually be considered a duplicate of that question, because the answer explicitly mentionsGraph
. $\endgroup$ToExpression[ StringReplace[ ToString[InputForm[allConnected[3]]], {"1" -> "a", "2" -> "b", "3" -> "c"}]]
$\endgroup$EntityClass["WolframLanguageSymbol", "Atomic"]//EntityList
$\endgroup$