Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

This is uncompleted answer for this postthis 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 answeraccepted 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

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

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

Notice removed Authoritative reference needed by CommunityBot
Bounty Ended with no winning answer by CommunityBot

How to deal with this sourethese source vertices?

Tweeted twitter.com/StackMma/status/809969296248029184
Notice added Authoritative reference needed by yode
Bounty Started worth 50 reputation by yode
added 84 characters in body
Source Link
yode
  • 27.2k
  • 4
  • 66
  • 174

This is uncompleted answer for this post based on NearestNeighborGraph.I'm lost in how to deal with that source vertexvertices(whose vertex in-degree is 0.) in graphg,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 circlecircles.They are all source vertexvertices.If I don't draw it.It,it will not be no overlap anymore:

Graphics[{Circle @@@ 
   Select[circle, VertexInDegree[g, First[#]] != 0 &]}]

enter image description here

This is uncompleted answer for this post based on NearestNeighborGraph.I'm lost in how to deal with that source vertex(whose vertex in-degree is 0.) in graph,but it has better efficiency.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 circle.They are all source vertex.If I don't draw it.It will be no overlap anymore:

Graphics[{Circle @@@ 
   Select[circle, VertexInDegree[g, First[#]] != 0 &]}]

enter image description here

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

Source Link
yode
  • 27.2k
  • 4
  • 66
  • 174
Loading