1
/* This software was developed by Bruce Hendrickson and Robert Leland *
2
* at Sandia National Laboratories under US Department of Energy *
3
* contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
10
void coarsen1(graph, nvtxs, nedges, pcgraph, pcnvtxs, pcnedges,
11
pv2cv, igeom, coords, ccoords, using_ewgts)
12
struct vtx_data **graph; /* array of vtx data for graph */
13
int nvtxs; /* number of vertices in graph */
14
int nedges; /* number of edges in graph */
15
struct vtx_data ***pcgraph; /* coarsened version of graph */
16
int *pcnvtxs; /* number of vtxs in coarsened graph */
17
int *pcnedges; /* number of edges in coarsened graph */
18
int **pv2cv; /* pointer to v2cv */
19
int igeom; /* dimension for geometric information */
20
float **coords; /* coordinates for vertices */
21
float **ccoords; /* coordinates for coarsened vertices */
22
int using_ewgts; /* are edge weights being used? */
24
extern double coarsen_time;
25
extern double match_time;
26
double time; /* time routine is entered */
27
int *v2cv; /* maps from vtxs to cvtxs */
28
int *mflag; /* flag indicating vtx matched or not */
29
int cnvtxs; /* number of vtxs in coarse graph */
30
int nmerged; /* number of edges contracted */
33
int sfree(), maxmatch();
34
void makev2cv(), makefgraph();
38
/* Allocate and initialize space. */
39
v2cv = (int *) smalloc((unsigned) (nvtxs + 1) * sizeof(int));
40
mflag = (int *) smalloc((unsigned) (nvtxs + 1) * sizeof(int));
42
/* Find a maximal matching in the graph. */
43
nmerged = maxmatch(graph, nvtxs, nedges, mflag, using_ewgts, igeom, coords);
44
match_time += seconds() - time;
46
/* Now construct coarser graph by contracting along matching edges. */
47
/* Pairs of values in mflag array indicate matched vertices. */
48
/* A zero value indicates that vertex is unmatched. */
52
makecgraph(graph, nvtxs, pcgraph, pcnvtxs, pcnedges, mflag,
53
*pv2cv, nmerged, using_ewgts, igeom, coords, ccoords);
54
makecgraph2(graph, nvtxs, nedges, pcgraph, pcnvtxs, pcnedges, mflag,
55
*pv2cv, nmerged, using_ewgts, igeom, coords, ccoords);
58
makev2cv(mflag, nvtxs, v2cv);
60
sfree((char *) mflag);
62
cnvtxs = nvtxs - nmerged;
63
makefgraph(graph, nvtxs, nedges, pcgraph, cnvtxs, pcnedges, v2cv,
64
using_ewgts, igeom, coords, ccoords);
69
coarsen_time += seconds() - time;