3

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]

enter image description here

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}]

enter image description here

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 &]}]

enter image description here

yode
  • 26,686
  • 4
  • 62
  • 167

0 Answers0