Versions 10.0-10.2 seem to have a bug when trying to set VertexCoordinates
twice on a graph (version 9.0 is fine). Can you confirm it? What is a good workaround that will not discard any other attached properties/attributes such as weights?
g = RandomGraph[BarabasiAlbertGraphDistribution[10, 1]]
(* set coordinates: *)
g = SetProperty[g, VertexCoordinates -> RandomReal[1, {10, 2}]]
(* trying to change them to something else fails *)
g = SetProperty[g, VertexCoordinates -> RandomReal[1, {10, 2}]]
This related post describes a problem with RemoveProperty
: I can't even remove the coordinates.
MapIndexed[(g = SetProperty[{g, First@#2}, VertexCoordinates -> #1]) &, RandomReal[1, {10, 2}]]
$\endgroup$VertexCoordinates
has been already set once. 2.First@#2
should beExtract[VertexList[g], #2]&
to deal with situations where the vertex index does not equal the vertex name. But this works:SetProperty[g, VertexCoordinates -> Thread[VertexList[g] -> RandomReal[1, {10, 2}]]]
. $\endgroup$Graph
stuff works. $\endgroup$Graph
stuff is not as consistent as the rest of Mathematica. $\endgroup$