Skip to main content
1 of 9
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

With the missing piece from halmir in How do I "read out" the vertex names on this graph? I can self-answer with a proof-of-concept using Nearest and Graph. Please don't let this post discourage answering as I am eager to see other approaches.

dd = Join @@ dat;
nf = Nearest[dd -> Automatic];
g1 = Graph[
   Join[
    Partition[Range@Length@dd, 2],
    Cases[nf /@ dd, {_, _}]
    ], VertexLabels -> "Name"
   ];
g2 = FindSpanningTree[g1, VertexLabels -> "Name"]

enter image description here

ord =
  Reap[DepthFirstScan[g2, Sort[near][[1, 1]], {"PrevisitVertex" -> Sow}];][[2, 1]]

(*  {9, 10, 1, 2, 4, 3, ..., 41, 34, 33} *)

ListLinePlot[dd[[ord]], Frame -> True]

enter image description here

The next step in improving this would be to extract direction data from ord to apply to full lines.

Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k