This is uncompleted answer for this post based on NearestNeighborGraph
.I'm lost in how to deal with that source vertices(whose vertex in-degree is 0.) in g
,but it has better efficiency than accepted answer currently.Maybe somebody can finish it,so I post it still:
SeedRandom[8]
p = RandomReal[10, {400, 2}];
g = NearestNeighborGraph[p, 1, DirectedEdges -> True]
c = Catenate[
Thread[Rule[List @@ #, EuclideanDistance @@ #/2]] & /@
First /@ FindCycle[g, {2}, All]];
circle = Catenate[
FixedPointList[
Function[c,
Rule[#, EuclideanDistance[#,
t = Last[VertexOutComponent[g, #, 1]]] - (t /. c)] & /@
Complement[VertexInComponent[g, First /@ c, 1], First /@ c]],
c]];
Graphics[{Circle @@@ circle}]
As you can see,there are some overlap circles.They are all source vertices.If I don't draw it,it will not be overlap anymore:
Graphics[{Circle @@@
Select[circle, VertexInDegree[g, First[#]] != 0 &]}]