karg.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "karger.h"
00003 #include "bc_zeit.h"
00004 
00005 extern int max_numiter;
00006 
00007 void  karg_usage (char *f);
00008 
00009 int main (int ac, char **av)
00010 {
00011    int i;
00012    int rval = 0;
00013    int ncount, ecount, ccount=0;
00014    int *elist = NULL;
00015    double *elen = NULL;
00016    setlist *sets = NULL;
00017    setlist *oldset = NULL;
00018    double szeit, maxtime;
00019    cuts_info cinf;
00020 
00021    if ( ac != 3 )
00022    {
00023       fprintf(stderr, "wrong parameters. should be: file.x time\n"); goto CLEANUP;
00024    }
00025 
00026    maxtime = atof(av[2]);
00027    fprintf(stderr, "file name = %s     time = %lf\n", av[1], atof(av[2]));
00028 
00029    rval = karg_getprob (av[1], &ncount, &ecount, &elist, &elen);
00030    if (rval) {
00031       fprintf (stderr, "karg_getprob failed\n"); goto CLEANUP;
00032    }
00033 
00034    cinf.val = 5;
00035 
00036    szeit = CCutil_zeit();
00037    max_numiter = 2000;
00038    rval = karger (ncount, ecount, elist, elen, 3, 6.0, maxtime, 0, &sets,
00039           choose_edge1, (void *)(&cinf), process_cut);
00040 
00041    printf ("Running Time: %.2f (seconds)\n", CCutil_zeit()-szeit); fflush (stdout);
00042 
00043    if (sets == NULL)
00044       printf("No cuts; failure\n");
00045 
00046    while (sets != NULL){
00047       ccount += 1;
00048     
00049       i = 0;
00050       printf("Cut value = %f\n", sets->cutval);
00051       /*
00052       for (i=0; i<sets->setn; i++){
00053          printf("%d ",sets->setv[i]);
00054       }
00055       printf("\n");
00056       */
00057       oldset = sets;
00058       sets = sets->next;
00059       free(oldset->setv);
00060       free(oldset);
00061    }
00062    if(elist) free(elist);
00063    if(elen) free(elen);
00064 
00065    printf("Number of cuts = %d.\n", ccount);
00066 
00067    fflush (stdout);
00068 
00069 CLEANUP:
00070    return 0;
00071 }
00072 

Generated on Thu Oct 20 14:58:41 2005 for DominoParitySeparator by  doxygen 1.4.5