


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solution to hw4 of stat 534 - minimal spanning tree, which includes the output of the test-mst.c program, a minimal spanning tree plot, and the source code of the mst.c function.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



x x
new edge, and the graph and point set are updated. The distance array at this index is set to -1, indicating that the row is obsolete and should be skipped in the pass through./ while (si_pts->current != NULL){ set_iterator_next(&vtx, si_vtx); min_dist = -1; for (i = 0; i < num_pts - 1; i++){ / initial pass through, all distances updated/ if (ini_dist == TRUE){ distance[i] = point_distance(isolated[i], vtx); fragment[i] = vtx;} / otherwise, skip if -1 or update dist as req/ else if (distance[i] != -1){ new_dist = point_distance(isolated[i], vtx); if (new_dist < distance[i]){ distance[i] = new_dist; fragment[i] = vtx; } } / update the min distance and pair/ if (distance[i] != -1){ if (min_dist == -1 || distance[i] < min_dist){ pair = i; min_dist = distance[i]; } } } / update graph, point set; use new vertex for next pass through*/ graph_add_edge(edge_make(isolated[pair], fragment[pair]), mstree); graph_add_vertex(isolated[pair], mstree); set_remove_element(isolated[pair], point_set); set_iterator_next(&vtx, si_vtx); distance[pair] = -1; set_iterator_reset(si_pts); ini_dist = FALSE; } return(mstree); }