/usr/include/rheolef/rcm.h is in librheolef-dev 5.93-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | #ifndef _RCM_H
#define _RCM_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
/* rcm.f -- translated by f2c (version 19931217).*/
/*****************************************************************/
/********* RCM ..... REVERSE CUTHILL-MCKEE ORDERING *******/
/*****************************************************************/
/* PURPOSE - RCM NUMBERS A CONNECTED COMPONENT SPECIFIED BY */
/* MASK AND ROOT, USING THE RCM ALGORITHM. */
/* THE NUMBERING IS TO BE STARTED AT THE NODE ROOT. */
/* */
/* INPUT PARAMETERS - */
/* ROOT - IS THE NODE THAT DEFINES THE CONNECTED */
/* COMPONENT AND IT IS USED AS THE STARTING */
/* NODE FOR THE RCM ORDERING. */
/* (XADJ, ADJNCY) - ADJACENCY STRUCTURE PAIR FOR */
/* THE GRAPH. */
/* */
/* UPDATED PARAMETERS - */
/* MASK - ONLY THOSE NODES WITH NONZERO INPUT MASK */
/* VALUES ARE CONSIDERED BY THE ROUTINE. THE */
/* NODES NUMBERED BY RCM WILL HAVE THEIR */
/* MASK VALUES SET TO ZERO. */
/* */
/* OUTPUT PARAMETERS - */
/* PERM - WILL CONTAIN THE RCM ORDERING. */
/* CCSIZE - IS THE SIZE OF THE CONNECTED COMPONENT */
/* THAT HAS BEEN NUMBERED BY RCM. */
/* */
/* WORKING PARAMETER - */
/* DEG - IS A TEMPORARY VECTOR USED TO HOLD THE DEGREE */
/* OF THE NODES IN THE SECTION GRAPH SPECIFIED */
/* BY MASK AND ROOT. */
/* */
/* PROGRAM SUBROUTINES - */
/* DEGREE. */
/* */
/****************************************************************/
#include "rheolef/degree.h"
namespace rheolef {
template <class Iterator>
void
rcm(
Iterator root,
Iterator xadj,
Iterator adjncy,
Iterator mask,
Iterator perm,
Iterator ccsize,
Iterator deg)
{
typedef typename std::iterator_traits<Iterator>::value_type Integer;
/* System generated locals */
Integer i__1, i__2;
/* Local variables */
static Integer node, fnbr, lnbr, i, j, k, l, lperm, jstop, jstrt;
static Integer lbegin, lvlend, nbr;
/* FIND THE DEGREES OF THE NODES IN THE */
/* COMPONENT SPECIFIED BY MASK AND ROOT. */
/* ------------------------------------- */
/* Parameter adjustments */
--deg;
--perm;
--mask;
--adjncy;
--xadj;
degree(root, &xadj[1], &adjncy[1], &mask[1], °[1], ccsize, &perm[1]);
mask[*root] = 0;
if (*ccsize <= 1) {
return;
}
lvlend = 0;
lnbr = 1;
/* LBEGIN AND LVLEND POINT TO THE BEGINNING AND */
/* THE END OF THE CURRENT LEVEL RESPECTIVELY. */
L100:
lbegin = lvlend + 1;
lvlend = lnbr;
i__1 = lvlend;
for (i = lbegin; i <= i__1; ++i) {
/* FOR EACH NODE IN CURRENT LEVEL ... */
node = perm[i];
jstrt = xadj[node];
jstop = xadj[node + 1] - 1;
/* FIND THE UNNUMBERED NEIGHBORS OF NODE. */
/* FNBR AND LNBR POINT TO THE FIRST AND LAST */
/* UNNUMBERED NEIGHBORS RESPECTIVELY OF THE CURRENT */
/* NODE IN PERM. */
fnbr = lnbr + 1;
i__2 = jstop;
for (j = jstrt; j <= i__2; ++j) {
nbr = adjncy[j];
if (mask[nbr] == 0) {
goto L200;
}
++lnbr;
mask[nbr] = 0;
perm[lnbr] = nbr;
L200:
;
}
if (fnbr >= lnbr) {
goto L600;
}
/* SORT THE NEIGHBORS OF NODE IN INCREASING */
/* ORDER BY DEGREE. LINEAR INSERTION IS USED.*/
k = fnbr;
L300:
l = k;
++k;
nbr = perm[k];
L400:
if (l < fnbr) {
goto L500;
}
lperm = perm[l];
if (deg[lperm] <= deg[nbr]) {
goto L500;
}
perm[l + 1] = lperm;
--l;
goto L400;
L500:
perm[l + 1] = nbr;
if (k < lnbr) {
goto L300;
}
L600:
;
}
if (lnbr > lvlend) {
goto L100;
}
/* WE NOW HAVE THE CUTHILL MCKEE ORDERING.*/
/* REVERSE IT BELOW ...*/
k = *ccsize / 2;
l = *ccsize;
i__1 = k;
for (i = 1; i <= i__1; ++i) {
lperm = perm[l];
perm[l] = perm[i];
perm[i] = lperm;
--l;
}
return;
}
}// namespace rheolef
#endif // _RCM_H
|