~ubuntu-branches/ubuntu/precise/scotch/precise

« back to all changes in this revision

Viewing changes to src/libscotch/library_dgraph_coarsen.c

  • Committer: Package Import Robot
  • Author(s): "Adam C. Powell, IV"
  • Date: 2011-12-21 13:40:52 UTC
  • mfrom: (14.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20111221134052-1yw353l7p7zoo51d
Tags: 5.1.12b.dfsg-1
* New upstream (closes: #652900).
* Rebuild with new mpi-defaults (closes: #652311).
* Forward-ported build-fixes.patch (just shifted one hunk two lines).
* New build-arch and build-indep targets in rules.
* Updated VCS URLs.
* Bumped Standards-Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2011 ENSEIRB, INRIA & CNRS
 
2
**
 
3
** This file is part of the Scotch software package for static mapping,
 
4
** graph partitioning and sparse matrix ordering.
 
5
**
 
6
** This software is governed by the CeCILL-C license under French law
 
7
** and abiding by the rules of distribution of free software. You can
 
8
** use, modify and/or redistribute the software under the terms of the
 
9
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
 
10
** URL: "http://www.cecill.info".
 
11
** 
 
12
** As a counterpart to the access to the source code and rights to copy,
 
13
** modify and redistribute granted by the license, users are provided
 
14
** only with a limited warranty and the software's author, the holder of
 
15
** the economic rights, and the successive licensors have only limited
 
16
** liability.
 
17
** 
 
18
** In this respect, the user's attention is drawn to the risks associated
 
19
** with loading, using, modifying and/or developing or reproducing the
 
20
** software by the user in light of its specific status of free software,
 
21
** that may mean that it is complicated to manipulate, and that also
 
22
** therefore means that it is reserved for developers and experienced
 
23
** professionals having in-depth computer knowledge. Users are therefore
 
24
** encouraged to load and test the software's suitability as regards
 
25
** their requirements in conditions enabling the security of their
 
26
** systems and/or data to be ensured and, more generally, to use and
 
27
** operate it in the same conditions as regards security.
 
28
** 
 
29
** The fact that you are presently reading this means that you have had
 
30
** knowledge of the CeCILL-C license and that you accept its terms.
 
31
*/
 
32
/************************************************************/
 
33
/**                                                        **/
 
34
/**   NAME       : library_dgraph_coarsen.c                **/
 
35
/**                                                        **/
 
36
/**   AUTHOR     : Francois PELLEGRINI                     **/
 
37
/**                                                        **/
 
38
/**   FUNCTION   : This module is the API for the          **/
 
39
/**                distributed graph coarsening routine of **/
 
40
/**                the libSCOTCH library.                  **/
 
41
/**                                                        **/
 
42
/**   DATES      : # Version 5.1  : from : 07 aug 2011     **/
 
43
/**                                 to     07 aug 2011     **/
 
44
/**                                                        **/
 
45
/************************************************************/
 
46
 
 
47
/*
 
48
**  The defines and includes.
 
49
*/
 
50
 
 
51
#define LIBRARY
 
52
 
 
53
#include "module.h"
 
54
#include "common.h"
 
55
#include "dgraph.h"
 
56
#include "dgraph_coarsen.h"
 
57
#include "scotch.h"
 
58
 
 
59
/************************************/
 
60
/*                                  */
 
61
/* This routine is the C API for    */
 
62
/* the distributed graph coarsening */
 
63
/* routine.                         */
 
64
/*                                  */
 
65
/************************************/
 
66
 
 
67
/*+ This routine creates a distributed coarse graph
 
68
*** from the given fine graph, unless the coarse graph
 
69
*** is smaller than some threshold size or the
 
70
*** coarsening ratio is above some other threshold.
 
71
*** If the coarse graph is created, a coarse-to-fine
 
72
*** vertex array is created, that contains a pair of
 
73
*** fine indices for each coarse index. It is the
 
74
*** user's responsibility to free this array when it
 
75
*** is no longer needed.
 
76
*** It returns:
 
77
*** - 0  : if the graph has been coarsened.
 
78
*** - 1  : if the graph could not be coarsened.
 
79
*** - 2  : on error.
 
80
+*/
 
81
 
 
82
int
 
83
SCOTCH_dgraphCoarsen (
 
84
SCOTCH_Dgraph * restrict const  finegrafptr,      /* Fine graph structure to fill      */
 
85
SCOTCH_Dgraph * restrict const  coargrafptr,      /* Coarse graph                      */
 
86
SCOTCH_Num * restrict const     multloctab,       /* Pointer to multinode array        */
 
87
const SCOTCH_Num                coarnbr,          /* Minimum number of coarse vertices */
 
88
const double                    coarrat)          /* Maximum contraction ratio         */
 
89
{
 
90
  DgraphCoarsenMulti * restrict multlocptr;
 
91
  int                           o;
 
92
 
 
93
  o = dgraphCoarsen ((Dgraph * restrict const) finegrafptr, (Dgraph * restrict const) coargrafptr,
 
94
                     &multlocptr, 5, coarnbr, 0, 0, coarrat);
 
95
 
 
96
  if (o == 0) {                                   /* If coarsening succeeded */
 
97
    SCOTCH_Num          coarvertnbr;
 
98
 
 
99
    SCOTCH_dgraphSize (coargrafptr, NULL, &coarvertnbr, NULL, NULL); /* Get number of local coarse vertices */
 
100
    memCpy (multloctab, multlocptr, coarvertnbr * 2 * sizeof (Gnum));
 
101
  }
 
102
 
 
103
  return (o);
 
104
}