Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Euclidean Minimal Spanning Tree and Delaunay Triangulation

I want to calculate the minimal spanning tree based on the euclidean distance between a set of points on a 2D-plane. My current code stores all the edges, and then performs Prim's algorithm in order to get the minimal spanning tree. However, I am aware that doing this takes O(n^2) space for all the edges.

After doing some research, it becomes clear that the memory and runtime can be optimized if I calculate the delaunay triangulation first on this set of points, then obtain the minimal spanning tree via running Prim's or Kruskal's algorithm on the edges of the triangulation.

This is part of a programming contest (https://prologin.org/train/2017/qualification/taxi_des_neiges), so I doubt I'd be able to use scipy.spatial. Is there any alternatives to simply get the edges contained in the Delaunay triangulation?

Thanks in advance.

like image 305
Jingjie YANG Avatar asked Oct 22 '25 03:10

Jingjie YANG


1 Answers

Would a module help? Here's a few that might work:

  • delaunator
  • poly2tri
  • triangle
  • matplotlib?

Roll your own? Both of these describe the incremental algorithm, which Wikipedia seems to say is O(n log n):

  • http://www.geom.uiuc.edu/~samuelp/del_project.html
  • http://graphics.stanford.edu/courses/cs368-06-spring/handouts/Delaunay_1.pdf

Here's an ActiveState recipe that might help to get started, but it looks like it's not finished.

like image 87
wildwilhelm Avatar answered Oct 23 '25 15:10

wildwilhelm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!