Say I have a Graph with some labels, and I want to change one of the labels. For example
graph = Graph[
{1, 2, 3},
{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1},
VertexLabels -> {1 -> "someLabel"}
];
I now want to change the label from "someLabel" to "someOtherLabel".
Naively, I would do this by simply using ReplaceAll: graph /. "someLabel" -> "someOtherLabel".
However, this doesn't seem to work for Graph expressions, I guess because they are treated as atomic by Mathematica.
How can I do this? More generally, is there an easy way to convert a Graph object into its generating expression, so that I can modify it?
SetProperty[]? – J. M.'s missing motivation May 17 '20 at 17:31Graphinto a "normal" (i.e. non atomic) expression? – glS May 17 '20 at 17:41Nucleus[]might be what you want for that case. – J. M.'s missing motivation May 17 '20 at 17:44