I have a table of random geometric graphs
graphs = Table[ RandomGraph[ SpatialGraphDistribution[ RandomVariate[PoissonDistribution[100]], 0.2]], {k, 1, 10}];
but I need the EdgeWeights
of each graph to be the Euclidean distances between the vertices of the respective edge. At the moment they are all unity.
I tried using
graphs = SetProperty[#, EdgeWeight -> EuclideanDistance @@@ EdgeList[#]] & /@ graphs;
but this obviously requires the vertex names to be position vectors. I also tried using
vertlist[graph_] := VertexCoordinates /. AbsoluteOptions[graph, VertexCoordinates]
with another function which threads over the edges, but it seems inelegant...
Is there a simpler way?