00001 #include "eg_ddomino_app.h"
00002
00003 int EGddominoTest (char *file_name)
00004 {
00005
00006 int i,
00007 rval;
00008 FILE *file;
00009
00010 int nnodes,
00011 nedges,
00012 *edges;
00013 EGdijkstraCost_t *weight;
00014
00015 double dtmp;
00016
00017 size_t *os = 0;
00018 EGlist_t *dlist;
00019
00020 EGdGraph_t *G;
00021
00022 EGtimer_t my_timer;
00023 EGmemPool_t *mem;
00024
00025
00026
00027 file = fopen (file_name, "r");
00028 TEST (!file, "unable to open file %s", file_name);
00029
00030 fscanf (file, "%d %d", &nnodes, &nedges);
00031
00032 edges = (int *) malloc (sizeof (int) * nedges * 2);
00033 weight = (EGdijkstraCost_t *) malloc (sizeof (EGdijkstraCost_t) * nedges);
00034
00035 for (i = 0; i < nedges; i++)
00036 {
00037 fscanf (file, "%d %d %lf", &edges[2 * i], &edges[2 * i + 1], &dtmp);
00038 weight[i] = EGdijkstraToCost (dtmp);
00039 }
00040
00041 fclose (file);
00042
00043
00044
00045 mem = EGnewMemPool (8192, EGmemPoolNewSize, EGmemPoolNewSize (1));
00046
00047 G = EGnewMengerGraph (mem, nnodes, nedges, edges, weight, &os);
00048
00049 EGtimerReset (&my_timer);
00050 EGtimerStart (&my_timer);
00051
00052 dlist = EGnewList (mem);
00053
00054 rval = EGddominoComputeAll (mem, G, dlist);
00055 CHECKRVAL (rval);
00056
00057 EGtimerStop (&my_timer);
00058
00059 fprintf (stderr, "Found %u ddominoes.\n", dlist->size);
00060 fprintf (stderr, "Time: %lf\n", my_timer.time);
00061
00062
00063
00064 EGmemPoolFree (os, sizeof (size_t) * 13, mem);
00065
00066 EGdGraphClearMP (G, EGfreeMengerEdgeDataMP, EGfreeMengerNodeDataMP, 0, mem,
00067 mem, 0);
00068 EGfreeDGraph (G);
00069
00070 EGfreeAllDDominoes (dlist, mem);
00071 EGfreeList (dlist);
00072 EGfreeMemPool (mem);
00073
00074 free (edges);
00075 free (weight);
00076
00077 return 0;
00078
00079 }