~ubuntu-branches/debian/squeeze/gmsh/squeeze

« back to all changes in this revision

Viewing changes to contrib/Chaco/coarsen/coarsen1.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2009-01-07 16:02:08 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090107160208-vklhtj69br5yw5bh
Tags: 2.2.6.dfsg-2
* debian/control: fixed lintian warning "debhelper-but-no-misc-depends"
* debian/watch: fixed lintian warning
  "debian-watch-file-should-mangle-version"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
#include <stdio.h>
 
6
#include "defs.h"
 
7
#include "structs.h"
 
8
 
 
9
 
 
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? */
 
23
{
 
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 */
 
31
    double   *smalloc();
 
32
    double    seconds();
 
33
    int       sfree(), maxmatch();
 
34
    void      makev2cv(), makefgraph();
 
35
 
 
36
    time = seconds();
 
37
 
 
38
    /* Allocate and initialize space. */
 
39
    v2cv = (int *) smalloc((unsigned) (nvtxs + 1) * sizeof(int));
 
40
    mflag = (int *) smalloc((unsigned) (nvtxs + 1) * sizeof(int));
 
41
 
 
42
    /* Find a maximal matching in the graph. */
 
43
    nmerged = maxmatch(graph, nvtxs, nedges, mflag, using_ewgts, igeom, coords);
 
44
    match_time += seconds() - time;
 
45
 
 
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. */
 
49
 
 
50
 
 
51
/*
 
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);
 
56
*/
 
57
 
 
58
    makev2cv(mflag, nvtxs, v2cv);
 
59
 
 
60
    sfree((char *) mflag);
 
61
 
 
62
    cnvtxs = nvtxs - nmerged;
 
63
    makefgraph(graph, nvtxs, nedges, pcgraph, cnvtxs, pcnedges, v2cv,
 
64
                         using_ewgts, igeom, coords, ccoords);
 
65
    
 
66
 
 
67
    *pcnvtxs = cnvtxs;
 
68
    *pv2cv = v2cv;
 
69
    coarsen_time += seconds() - time;
 
70
}