Euclidean Minimum Spanning TreesThe Euclidean minimum spanning tree of a point set A Euclidean minimum spanning tree for a set of points
Example
#include <LEDA/core/list.h> #include <LEDA/geo/rat_point.h> #include <LEDA/geo/random_rat_point.h> #include <LEDA/graphics/window.h> #include <LEDA/geo/geo_alg.h> using namespace leda; int main() { list<rat_point> L; random_points_in_square(25,100,L); GRAPH<rat_point,int> G; MIN_SPANNING_TREE(L,G); window W; W.init(-110,110,-110); W.open(); W.display(); W.set_node_width(4); W.set_line_width(3); rat_point p; //draw points in L forall(p,L) {W.draw_filled_node(p.to_point(),black);} W.read_mouse(); edge e; forall_edges(e,G) { //MST point p=G[G.source(e)].to_point(); point q=G[G.target(e)].to_point(); W.draw_edge(p,q,red); } W.read_mouse(); W.screenshot("euclidean_MST"); return 0; } |
See also:Manual Entries |