2
$\begingroup$

The function RandomGraph[SpatialGraphDistribution[n, r]] generates a random geometric graph over $[0,1]^2$ where vertices are connected if they are within a distance $r$ of one-another.

How would I explicitly specify a list of points for generating a random geometric graph using this function? Specifically, I need to enforce a minimum threshold distance between points.

Clarification: My point list is going to come from a Random Sequential Adsorption (RSA) simulation of circles on a plane. So I mean that no two points should be closer than some minimum threshold distance set by the radius of the circles being deposited, not that two points shouldn't share an edge if they are closer than the threshold distance.

$\endgroup$
  • $\begingroup$ After reading the clarification, I'm not sure I understand what you're asking. Is this what you need? $\endgroup$ – Szabolcs Apr 9 '13 at 14:33
  • $\begingroup$ @Szabolcs Oh, no I'm just asking to be able to feed a set of points to SpatialGraphDistribution that I've already generated by simulating Random Sequential Adsorption (RSA). My understanding, from the literature, is that this random packing process must be simulated. $\endgroup$ – M.Y. Apr 10 '13 at 2:16
  • $\begingroup$ @Szabolcs I think you're answer is the answer I was looking for - it can't be done, so I have to rely on my own implementation. $\endgroup$ – M.Y. Apr 10 '13 at 2:16
2
$\begingroup$

With SpatialGraphDistribution it's not possible, as this is used for representing a distribution. You were asking, "How would I explicitly specify a list of points for generating a random geometric graph", but if you give a set of points, then the graph is not random any more, so SpatialGraphDistribution won't be of use.


I would proceed like this:

Take a set of points (you'll already have this list from another source):

pts = RandomReal[1, {100, 2}];

Calculate pairwise distances:

distances = 
  With[{tr = Transpose[pts]}, 
   Function[point, Sqrt[Total[(point - tr)^2]]] /@ pts];

Build an adjacency matrix, taking care not to connect each node to itself:

am = UnitStep[r - distances] - IdentityMatrix@Length[pts];

Convert it to a graph:

AdjacencyGraph[am, VertexCoordinates -> pts]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.