1
/* Copyright 2004,2007 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 : bgraph_check.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This module contains the bipartition **/
39
/** graph consistency checking routine. **/
41
/** DATES : # Version 4.0 : from : 08 jan 2004 **/
42
/** to 07 dec 2005 **/
44
/************************************************************/
47
** The defines and includes.
58
/*************************/
60
/* These routines handle */
61
/* bipartition graphs. */
63
/*************************/
65
/* This routine checks the consistency
66
** of the given bipartition graph.
68
** - 0 : if graph data are consistent.
74
const Bgraph * restrict const grafptr)
76
int * restrict flagtax; /* Frontier flag array */
77
Gnum vertnum; /* Number of current vertex */
78
Gnum fronnum; /* Number of frontier vertex */
87
if ((flagtax = memAlloc (grafptr->s.vertnbr * sizeof (Gnum))) == NULL) {
88
errorPrint ("bgraphCheck: out of memory");
91
memSet (flagtax, ~0, grafptr->s.vertnbr * sizeof (Gnum));
92
flagtax -= grafptr->s.baseval;
94
if (grafptr->compload0 != (grafptr->compload0avg + grafptr->compload0dlt)) {
95
errorPrint ("bgraphCheck: invalid balance");
99
for (vertnum = grafptr->s.baseval; vertnum < grafptr->s.vertnnd; vertnum ++) {
100
if (grafptr->parttax[vertnum] > 1) {
101
errorPrint ("bgraphCheck: invalid part array");
106
if ((grafptr->fronnbr < 0) ||
107
(grafptr->fronnbr > grafptr->s.vertnbr)) {
108
errorPrint ("bgraphCheck: invalid number of frontier vertices");
111
for (fronnum = 0; fronnum < grafptr->fronnbr; fronnum ++) {
117
vertnum = grafptr->frontab[fronnum];
118
if ((vertnum < grafptr->s.baseval) || (vertnum >= grafptr->s.vertnnd)) {
119
errorPrint ("bgraphCheck: invalid vertex index in frontier array");
122
if (flagtax[vertnum] != ~0) {
123
errorPrint ("bgraphCheck: duplicate vertex in frontier array");
126
flagtax[vertnum] = 0;
127
partval = grafptr->parttax[vertnum];
129
for (edgenum = grafptr->s.verttax[vertnum], commcut = 0;
130
edgenum < grafptr->s.vendtax[vertnum]; edgenum ++) {
133
partdlt = grafptr->parttax[grafptr->s.edgetax[edgenum]] ^ partval;
137
errorPrint ("bgraphCheck: invalid vertex in frontier array");
147
commloadextn = grafptr->commloadextn0;
149
edloval = 1; /* Assume edges are not weighted */
150
for (vertnum = grafptr->s.baseval; vertnum < grafptr->s.vertnnd; vertnum ++) {
151
Gnum partval; /* Part of current vertex */
152
Gnum edgenum; /* Number of current edge */
154
partval = (Gnum) grafptr->parttax[vertnum];
155
if (grafptr->veextax != NULL) {
158
veexval = grafptr->veextax[vertnum];
159
commloadextn += veexval * partval;
160
commgainextn += veexval * (1 - 2 * partval);
163
compload[partval] += (grafptr->s.velotax == NULL) ? 1 : grafptr->s.velotax[vertnum];
164
compsize[partval] ++;
168
for (edgenum = grafptr->s.verttax[vertnum]; edgenum < grafptr->s.vendtax[vertnum]; edgenum ++) {
172
if (grafptr->s.edlotax != NULL)
173
edloval = grafptr->s.edlotax[edgenum];
174
partend = grafptr->parttax[grafptr->s.edgetax[edgenum]];
175
partdlt = partval ^ partend;
177
commloadintn += partdlt * edloval * partend; /* Only count loads once, when (partend == 1) */
180
if ((commcut[0] != 0) && (commcut[1] != 0) && /* If vertex should be in separator */
181
(flagtax[vertnum] != 0)) {
182
errorPrint ("bgraphCheck: vertex should be in separator");
186
if (compsize[0] != grafptr->compsize0) {
187
errorPrint ("bgraphCheck: invalid part size");
190
if ((commloadintn * grafptr->domdist + commloadextn) != grafptr->commload) {
191
errorPrint ("bgraphCheck: invalid communication loads");
194
if (commgainextn != grafptr->commgainextn) {
195
errorPrint ("bgraphCheck: invalid communication gains");
199
memFree (flagtax + grafptr->s.baseval);