Skip to main content
added 59 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]]cc = ConnectedComponents[NearestNeighborGraph[points]];
ListPlot[cc, 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

UpdateUpdate: Labeling all points consecutively:

ListPlot[Joinlabeling = AssociationThread[Join @@ ConnectedComponents[NearestNeighborGraph[points]]MapIndexed[#2 ->&, 
 cc, {2}], Range Range[Length@ Length @ points]points];
ListPlot[cc, 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]]labeling @ #2 &)]

enter image description hereenter image description here

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Update:

ListPlot[Join @@ ConnectedComponents[NearestNeighborGraph[points]] -> 
    Range[Length @ points], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Perhaps something like this:

cc = ConnectedComponents[NearestNeighborGraph[points]];
ListPlot[cc, 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Update: Labeling all points consecutively:

labeling = AssociationThread[Join @@ MapIndexed[#2 &, cc, {2}], Range @ Length @ points];
ListPlot[cc, 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (labeling @ #2 &)]

enter image description here

added 335 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Update:

ListPlot[Join @@ ConnectedComponents[NearestNeighborGraph[points]] -> 
   Range[Length @ points], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Update:

ListPlot[Join @@ ConnectedComponents[NearestNeighborGraph[points]] -> 
   Range[Length @ points], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Perhaps something like this:

ListPlot[ConnectedComponents[NearestNeighborGraph[points]], 
 BaseStyle -> PointSize[Medium], 
 ImageSize -> 700, 
 Axes -> False, 
 LabelingFunction -> (#2[[-1]] &)]

enter image description here