3
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Can you be clearer about what the question is that you need help with? $\endgroup$
    – bill s
    Commented Dec 16, 2016 at 17:49
  • $\begingroup$ @bills I want to by this thinking to solve that link question to avoid to use violence method like as the current accepted answer. $\endgroup$
    – yode
    Commented Dec 16, 2016 at 17:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.