For the purposes of further development of my shortInputForm function, I wish to convert Atomic
objects such as Graph
into non-atomic Mathematica expressions (not the InputForm
strings!) where Graph
head itself would be temporarily inactivated. The following obvious method is ugly, highly inefficient, and potentially can have undesirable side-effects:
g = Graph[{UndirectedEdge[1, 2], UndirectedEdge[2, 3], UndirectedEdge[3, 1]}];
ToExpression[StringReplace[ToString[g, InputForm], "Graph" -> "Inactive[Graph]"]]
Is there a better way to "un-evaluate" a Graph
object?
Rational
s can also not be made compound this way. You can also try other serialization formats such asCompress
or WXF (though I think WXF supports NumericArray directly) $\endgroup$