/* cs2me3 * Winter 2004 * by Michael Soltys */ #include #define TRUE 1 typedef struct { int i; int j; int w; } edge; FILE *fpt; void sort_by_weight(int E, edge *graph) { /* Sorts the edges of graph in non-decreasing order by weights. */ } void spanning_tree(int N, int E, edge *graph) { /* Compute the spanning tree of graph where edges are assumed to be * already ordered by weights--unnecessary edges will get their * weights set to 0. */ } main(int argc, char *argv[]) { int N; /* number of nodes */ int E=0; /* number of edges */ edge *graph; /* input graph */ int flag=TRUE; int c=0; edge x; fpt = fopen(argv[1], "r"); fscanf(fpt, "%d", &N); /* allocate memory for a graph of size at most (N*N) */ graph=(edge *) malloc(N*N*sizeof(edge)); while (flag) { fscanf(fpt, "%d %d %d", &x.i, &x.j, &x.w); if (x.i==-1) break; graph[E]=x; E++; } fclose(fpt); sort_by_weight(E, graph); spanning_tree(N, E, graph); while (c