Is it possible to get the (x, y) position of nodes in a `Graph`?
Yes, use GraphEmbedding
.
Graph
is atomic and you should not try to extract any information from it by looking at its input form. It is not reliable, can change between versions, undocumented, etc. Nor is the input form directly accessible with things like Part
.
Alternatively, one can use AbsoluteOptions[]
to extract the coordinates:
g = RandomGraph[{20, 40}];
coords = VertexCoordinates /. AbsoluteOptions[g, VertexCoordinates];
You can verify that coords === GraphEmbedding[g]
gives True
.