Bug #1267: Integrate METIS graph partitioning library
[charm.git] / src / libs / ck-libs / metis / programs / cmpfillin.c
blobe1de447d797298cbc42e3b65eb4391fe770efeb4
1 /*
2 * Copyright 1997, Regents of the University of Minnesota
4 * cmpfillin.c
6 * This file takes a graph and a fill-reducing ordering and computes
7 * the fillin.
9 * Started 9/1/2004
10 * George
12 * $Id: cmpfillin.c 9982 2011-05-25 17:18:00Z karypis $
16 #include "metisbin.h"
20 /*************************************************************************
21 * Let the game begin
22 **************************************************************************/
23 int main(int argc, char *argv[])
25 idx_t i;
26 idx_t *perm, *iperm;
27 graph_t *graph;
28 params_t params;
29 size_t maxlnz, opc;
31 if (argc != 3) {
32 printf("Usage: %s <GraphFile> <PermFile\n", argv[0]);
33 exit(0);
36 params.filename = gk_strdup(argv[1]);
37 graph = ReadGraph(&params);
38 if (graph->nvtxs <= 0) {
39 printf("Empty graph. Nothing to do.\n");
40 exit(0);
42 if (graph->ncon != 1) {
43 printf("Ordering can only be applied to graphs with one constraint.\n");
44 exit(0);
48 /* Read the external iperm vector */
49 perm = imalloc(graph->nvtxs, "main: perm");
50 iperm = imalloc(graph->nvtxs, "main: iperm");
51 ReadPOVector(graph, argv[2], iperm);
53 for (i=0; i<graph->nvtxs; i++)
54 perm[iperm[i]] = i;
56 printf("**********************************************************************\n");
57 printf("%s", METISTITLE);
58 printf("Graph Information ---------------------------------------------------\n");
59 printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n\n", argv[1],
60 graph->nvtxs, graph->nedges/2);
61 printf("Fillin... -----------------------------------------------------------\n");
63 ComputeFillIn(graph, perm, iperm, &maxlnz, &opc);
65 printf(" Nonzeros: %6.3le \tOperation Count: %6.3le\n", (double)maxlnz, (double)opc);
68 printf("**********************************************************************\n");
70 FreeGraph(&graph);