# Include
# Define Max 100 typedef struct {int u; int v; int weight;} edge; edge edges [Max]; int nodes [Max]; void interchange (edge * m, edge * n) {edge temp = * m; * m = * n; * n = temp;} int partition (edge array [], int p, int q) {int I, j; I = p; j = q + 1; while (1) {do I ++; while (array [I]. weightarray [p]. weight) & (j! = P); if (I
> Nodenum> edgenum; cout <"Enter the start, end, and weight of each edge:" <
> Edges [I]. u> edges [I]. v> edges [I]. weight;} for (I = 1; I <= nodenum; I ++) nodes [I] = 0; quicksort (edges, 0, edgenum-1); for (I = 0; I <edgenum; I ++) {m = edges [I]. u; n = edges [I]. v; safe = 0; if (nodes [m] = 0 & nodes [n] = 0) {nodes [m] = flag; nodes [n] = flag; flag ++; safe = 1; // a safe edge} else {if (nodes [m] = 0 | nodes [n] = 0) {if (nodes [m] = 0) nodes [m] = nodes [n]; else nodes [n] = nodes [m]; safe = 1; // a sa Fe edge} else if (nodes [m]! = Nodes [n]) {for (j = 1; j <= nodenum; j ++) {if (nodes [j] = nodes [m] | nodes [j] = nodes [n]) & (j! = M & j! = N) {nodes [j] = flag ;}} nodes [m] = flag; nodes [n] = flag; flag ++; safe = 1; // a safe edge }}if (safe = 1) {// reserve a safe edge edges [presult]. u = m; edges [presult]. v = n; edges [presult]. weight = edges [I]. weight; presult ++;} if (presult = nodenum-1) {// found mst break;} cout <"Print the result:" <