// MST based on Warshall's algorithm (Maggs & Plotkin, // Information Processing Letters 26, 25 Jan 1988, 291-293) // 3/6/03 BPW // Modified 7/15/04 to make more robust, especially edges with same weight #include #define maxSize (20) struct edge { int weight,smallLabel,largeLabel; }; typedef struct edge edgeType; edgeType min(edgeType x,edgeType y) { // Returns smaller-weighted edge, using lexicographic tie-breaker if (x.weighty.weight) return y; if (x.smallLabely.smallLabel) return y; if (x.largeLabely.weight) return x; if (x.weighty.smallLabel) return x; if (x.smallLabely.largeLabel) return x; return y; } int main() { int numVertices,numEdges, i, j, k; edgeType matrix[maxSize][maxSize]; int count; printf("enter # of vertices and edges: "); fflush(stdout); scanf("%d %d",&numVertices,&numEdges); printf("enter undirected edges u v weight\n"); for (i=0;i=numVertices) printf("Error? . . . \n"); }