ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
coarsen.c
Go to the documentation of this file.
1 /*
2  * coarsen.c
3  *
4  * This file contains the driving routines for the coarsening process
5  *
6  * Started 7/23/97
7  * George
8  *
9  * $Id: coarsen.c,v 1.1 1998/11/27 17:59:12 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 clevel;
22  GraphType *cgraph;
23 
24  IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->CoarsenTmr));
25 
26  cgraph = graph;
27 
28  /* The following is ahack to allow the multiple bisections to go through with correct
29  coarsening */
30  if (ctrl->CType > 20) {
31  clevel = 1;
32  ctrl->CType -= 20;
33  }
34  else
35  clevel = 0;
36 
37  do {
38  IFSET(ctrl->dbglvl, DBG_COARSEN, printf("%6d %7d [%d] [%d %d]\n",
39  cgraph->nvtxs, cgraph->nedges, ctrl->CoarsenTo, ctrl->maxvwgt,
40  (cgraph->vwgt ? idxsum(cgraph->nvtxs, cgraph->vwgt) : cgraph->nvtxs)));
41 
42  if (cgraph->adjwgt) {
43  switch (ctrl->CType) {
44  case MATCH_RM:
45  Match_RM(ctrl, cgraph);
46  break;
47  case MATCH_HEM:
48  if (clevel < 1)
49  Match_RM(ctrl, cgraph);
50  else
51  Match_HEM(ctrl, cgraph);
52  break;
53  case MATCH_HEMN:
54  if (clevel < 1)
55  Match_RM(ctrl, cgraph);
56  else
57  Match_HEMN(ctrl, cgraph);
58  break;
59  case MATCH_SHEMN:
60  //if (clevel < 1)
61  // Match_RM(ctrl, cgraph);
62  //else
63  Match_SHEMN(ctrl, cgraph);
64  break;
65  case MATCH_SHEM:
66  if (clevel < 1)
67  Match_RM(ctrl, cgraph);
68  else
69  Match_SHEM(ctrl, cgraph);
70  break;
71  case MATCH_SHEMKWAY:
72  Match_SHEM(ctrl, cgraph);
73  break;
74  default:
75  graclus_errexit("Unknown CType: %d\n", ctrl->CType);
76  }
77  }
78  else {
79  Match_RM_NVW(ctrl, cgraph);
80  }
81 
82  cgraph = cgraph->coarser;
83  clevel++;
84  //printf("Coarsening to level %d, number of vertices is %d...\n", clevel, cgraph->nvtxs);
85  } while (cgraph->nvtxs > ctrl->CoarsenTo && cgraph->nvtxs < COARSEN_FRACTION2*cgraph->finer->nvtxs && cgraph->nedges > cgraph->nvtxs/2);
86 
87 
88  IFSET(ctrl->dbglvl, DBG_COARSEN, printf("%6d %7d [%d] [%d %d]\n",
89  cgraph->nvtxs, cgraph->nedges, ctrl->CoarsenTo, ctrl->maxvwgt,
90  (cgraph->vwgt ? idxsum(cgraph->nvtxs, cgraph->vwgt) : cgraph->nvtxs)));
91 
92  IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->CoarsenTmr));
93 
94  return cgraph;
95 }
96 
GraphType * Coarsen2Way(CtrlType *ctrl, GraphType *graph)
Definition: coarsen.c:19
#define MATCH_HEMN
Definition: defs.h:124
#define DBG_COARSEN
Definition: defs.h:176
#define MATCH_HEM
Definition: defs.h:117
#define MATCH_SHEM
Definition: defs.h:118
#define MATCH_RM
Definition: defs.h:116
#define COARSEN_FRACTION2
Definition: defs.h:162
#define MATCH_SHEMN
Definition: defs.h:125
#define MATCH_SHEMKWAY
Definition: defs.h:119
#define DBG_TIME
Definition: defs.h:174
#define stoptimer(tmr)
Definition: macros.h:49
#define IFSET(a, flag, cmd)
Definition: macros.h:56
#define starttimer(tmr)
Definition: macros.h:48
void Match_SHEMN(CtrlType *ctrl, GraphType *graph)
Definition: match.c:21
void Match_HEMN(CtrlType *ctrl, GraphType *graph)
Definition: match.c:116
void graclus_errexit(char *,...)
Definition: util.c:98
#define Match_SHEM
Definition: rename.h:142
#define Match_RM
Definition: rename.h:139
#define idxsum
Definition: rename.h:399
#define Match_HEM
Definition: rename.h:141
#define Match_RM_NVW
Definition: rename.h:140
int dbglvl
Definition: struct.h:224
timer CoarsenTmr
Definition: struct.h:238
int CType
Definition: struct.h:225
int maxvwgt
Definition: struct.h:228
int CoarsenTo
Definition: struct.h:223
int nvtxs
Definition: struct.h:168
idxtype * vwgt
Definition: struct.h:170
struct graphdef * finer
Definition: struct.h:205
int nedges
Definition: struct.h:168
idxtype * adjwgt
Definition: struct.h:173
struct graphdef * coarser
Definition: struct.h:205