Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
mcoarsen.c
Go to the documentation of this file.
1 /*
2  * mcoarsen.c
3  *
4  * This file contains the driving routines for the coarsening process
5  *
6  * Started 7/23/97
7  * George
8  *
9  * $Id: mcoarsen.c,v 1.1 1998/11/27 17:59:19 karypis Exp $
10  *
11  */
12 
13 #include <metis.h>
14 
15 
16 /*************************************************************************
17 * This function takes a graph and creates a sequence of coarser graphs
18 **************************************************************************/
20 {
21  int i, clevel;
22  GraphType *cgraph;
23 
24  IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->CoarsenTmr));
25 
26  cgraph = graph;
27 
28  clevel = 0;
29  do {
30  if (ctrl->dbglvl&DBG_COARSEN) {
31  printf("%6d %7d %10d [%d] [%6.4f", cgraph->nvtxs, cgraph->nedges,
32  idxsum(cgraph->nvtxs, cgraph->adjwgtsum), ctrl->CoarsenTo, ctrl->nmaxvwgt);
33  for (i=0; i<graph->ncon; i++)
34  printf(" %5.3f", ssum_strd(cgraph->nvtxs, cgraph->nvwgt+i, cgraph->ncon));
35  printf("]\n");
36  }
37 
38  switch (ctrl->CType) {
39  case MATCH_RM:
40  MCMatch_RM(ctrl, cgraph);
41  break;
42  case MATCH_HEM:
43  if (clevel < 1)
44  MCMatch_RM(ctrl, cgraph);
45  else
46  MCMatch_HEM(ctrl, cgraph);
47  break;
48  case MATCH_SHEM:
49  if (clevel < 1)
50  MCMatch_RM(ctrl, cgraph);
51  else
52  MCMatch_SHEM(ctrl, cgraph);
53  break;
54  case MATCH_SHEMKWAY:
55  MCMatch_SHEM(ctrl, cgraph);
56  break;
58  MCMatch_SHEBM(ctrl, cgraph, 1);
59  break;
61  MCMatch_SHEBM(ctrl, cgraph, -1);
62  break;
64  MCMatch_SBHEM(ctrl, cgraph, 1);
65  break;
67  MCMatch_SBHEM(ctrl, cgraph, -1);
68  break;
69  default:
70  errexit("Unknown CType: %d\n", ctrl->CType);
71  }
72 
73  cgraph = cgraph->coarser;
74  clevel++;
75 
76  } while (cgraph->nvtxs > ctrl->CoarsenTo && cgraph->nvtxs < COARSEN_FRACTION2*cgraph->finer->nvtxs && cgraph->nedges > cgraph->nvtxs/2);
77 
78  if (ctrl->dbglvl&DBG_COARSEN) {
79  printf("%6d %7d %10d [%d] [%6.4f", cgraph->nvtxs, cgraph->nedges,
80  idxsum(cgraph->nvtxs, cgraph->adjwgtsum), ctrl->CoarsenTo, ctrl->nmaxvwgt);
81  for (i=0; i<graph->ncon; i++)
82  printf(" %5.3f", ssum_strd(cgraph->nvtxs, cgraph->nvwgt+i, cgraph->ncon));
83  printf("]\n");
84  }
85 
86 
87  IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->CoarsenTmr));
88 
89  return cgraph;
90 }
91 
#define MATCH_RM
Definition: defs.h:98
idxtype * adjwgtsum
Definition: struct.h:168
#define MCCoarsen2Way
Definition: rename.h:157
struct graphdef * coarser
Definition: struct.h:198
#define idxsum
Definition: rename.h:399
#define stoptimer(tmr)
Definition: macros.h:54
struct graphdef * finer
Definition: struct.h:198
#define MATCH_SHEM
Definition: defs.h:100
HitTile_Vector graph
int CType
Definition: struct.h:217
#define MATCH_SBHEM_ONENORM
Definition: defs.h:104
#define MCMatch_HEM
Definition: rename.h:244
#define MCMatch_SBHEM
Definition: rename.h:247
float nmaxvwgt
Definition: struct.h:221
#define MATCH_SHEBM_INFNORM
Definition: defs.h:103
#define IFSET(a, flag, cmd)
Definition: macros.h:61
int dbglvl
Definition: struct.h:216
#define MATCH_SBHEM_INFNORM
Definition: defs.h:105
#define ssum_strd
Definition: rename.h:405
int CoarsenTo
Definition: struct.h:215
#define MATCH_SHEMKWAY
Definition: defs.h:101
int ncon
Definition: struct.h:194
#define MCMatch_RM
Definition: rename.h:243
#define errexit
Definition: rename.h:379
#define COARSEN_FRACTION2
Definition: defs.h:142
timer CoarsenTmr
Definition: struct.h:230
#define DBG_TIME
Definition: defs.h:154
int nedges
Definition: struct.h:161
#define MCMatch_SHEM
Definition: rename.h:245
int nvtxs
Definition: struct.h:161
#define DBG_COARSEN
Definition: defs.h:156
#define MATCH_SHEBM_ONENORM
Definition: defs.h:102
#define MATCH_HEM
Definition: defs.h:99
float * nvwgt
Definition: struct.h:195
#define MCMatch_SHEBM
Definition: rename.h:246
#define starttimer(tmr)
Definition: macros.h:53