Given a Graph with hard-coded vertex coordinates, how can we remove those coordinates without affecting any other graph properties? I am looking for a performant solution that uses only documented functionality.
Here’s a simple example. This is a graph with hard-coded vertex coordinates. It also has other properties such as edge weights and styling.
I can’t use Graph[g, GraphLayout -> "SpectralEmbedding"] because the coordinates are hard-coded. So how do I remove them without affecting anything else?
Simple tasks should have simple solutions. What is a simple solution here?
but I am not sure that this qualifies as either simple, performant or documented. I do not think I have seen such a use of Options with Graph in the documentation. Can I be sure that all options are extracted, and that they are extracted in a format that can be fed back to Graph? Performance is not very good on large graphs with properties.
This is basically the same problem as removing EdgeWeights to make a graph unweighted, which I asked about in the past.
I am aware of some undocumented means to change graph options with good performance, e.g. the ideas shown here. But I am not really happy with these. Graph expressions were clearly not meant to be accessed this way, so if I use such hacks, they might break in the next Mathematica version. If they break, I obviously can’t complain to Wolfram Support.
Removing edge weights or vertex coordinates is one of the most basic tasks one might want to do with a network.
I would like to know what solution Wolfram recommends for these simple tasks. Then I can use it confidently without worrying about breakage, or incorrect results due to misuse.
Some properties such as VertexCoordinates, VertexWeight and EdgeWeight are not modified by RemoveProperty due to a known issue. This issue will be fixed in the coming release. Your workaround is correct: