1
/* Copyright 2011 ENSEIRB, INRIA & CNRS
3
** This file is part of the Scotch software package for static mapping,
4
** graph partitioning and sparse matrix ordering.
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".
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
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.
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.
32
/************************************************************/
34
/** NAME : library_dgraph_coarsen.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This module is the API for the **/
39
/** distributed graph coarsening routine of **/
40
/** the libSCOTCH library. **/
42
/** DATES : # Version 5.1 : from : 07 aug 2011 **/
43
/** to 07 aug 2011 **/
45
/************************************************************/
48
** The defines and includes.
56
#include "dgraph_coarsen.h"
59
/************************************/
61
/* This routine is the C API for */
62
/* the distributed graph coarsening */
65
/************************************/
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.
77
*** - 0 : if the graph has been coarsened.
78
*** - 1 : if the graph could not be coarsened.
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 */
90
DgraphCoarsenMulti * restrict multlocptr;
93
o = dgraphCoarsen ((Dgraph * restrict const) finegrafptr, (Dgraph * restrict const) coargrafptr,
94
&multlocptr, 5, coarnbr, 0, 0, coarrat);
96
if (o == 0) { /* If coarsening succeeded */
97
SCOTCH_Num coarvertnbr;
99
SCOTCH_dgraphSize (coargrafptr, NULL, &coarvertnbr, NULL, NULL); /* Get number of local coarse vertices */
100
memCpy (multloctab, multlocptr, coarvertnbr * 2 * sizeof (Gnum));