int main(int argc, char *argv[]) { FILE *fp; graph g; int i; int total_colors[] = {0, 0, 0}; int max, min; if (argc != 2) { fprintf(stderr, "Usage: %s filename\n", argv[0]); exit(1); } fp = fopen(argv[1], "r"); if (fp == NULL) { fprintf(stderr, "Can't open file %s\n", argv[1]); exit(1); } read_graph(fp, &g, TRUE); //print_graph(&g); twocolor(&g); for (i=1; i<=(g.nvertices); i++) { //printf(" %d",color[i]); switch (color[i]) { case UNCOLORED: total_colors[0]++; break; case WHITE: total_colors[1]++; break; case BLACK: total_colors[2]++; break; } } #ifdef DEBUG printf("TOTAL: %d\n", g.nvertices); printf("WHITE: %d\n", total_colors[1]); printf("BLACK: %d\n", total_colors[2]); printf("UNCOLORED: %d\n", total_colors[0]); #endif max = (total_colors[1] > total_colors[2]) ? total_colors[1] : total_colors[2]; min = (total_colors[1] > total_colors[2]) ? total_colors[2] : total_colors[1]; printf("%d %d\n", max, min); return 0; }
int main() { graph g; int i; read_graph(&g,FALSE); print_graph(&g); twocolor(&g); printf("the color of nodes\n"); for (i=1; i<=(g.nvertices); i++) printf("%d: %d\n", i, color[i]); printf("\n"); return 0; }