1
$\begingroup$

I am trying to find a good way to draw a 1d random geometric graph, perhaps representing a string of cars on a road, connected in pairs when within radius 1.

One way is

RandomGraph[SpatialGraphDistribution[10, 1, 1]]

but, essentially, the problem is the edges are indistinguishable:

enter image description here

One solution is to have the edges curve slightly, so you can distinguish their endpoints. Is there some way to do this? Perhaps using EdgeShapeFunction?

$\endgroup$
3
$\begingroup$
SeedRandom[1]
RandomGraph[SpatialGraphDistribution[10, 1, 1], EdgeShapeFunction -> "CurvedArc"]

enter image description here

SeedRandom[1]
RandomGraph[SpatialGraphDistribution[10, 1, 1], EdgeShapeFunction -> "CurvedEdge"]

same picture

You can also use GraphLayout -> "LinearEmbedding"

SeedRandom[1]
RandomGraph[SpatialGraphDistribution[10, 1, 1], GraphLayout -> "LinearEmbedding"]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Ok that is ideal, thank you. $\endgroup$ – apkg Apr 27 at 11:54

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.