19 int adj_bandwidth (
int node_num,
int adj_num,
int adj_row[],
int adj[] )
76 for ( i = 0; i < node_num; i++ )
78 for ( j = adj_row[i]; j <= adj_row[i+1]-1; j++ )
81 band_lo =
i4_max ( band_lo, i - col );
82 band_hi =
i4_max ( band_hi, col - i );
86 value = band_lo + 1 + band_hi;
156 else if ( node_num < j )
173 for ( k = klo; k <= khi; k++ )
187 void adj_insert_ij (
int node_num,
int adj_max,
int *adj_num,
int adj_row[],
188 int adj[],
int i,
int j )
230 if ( adj_max < *adj_num + 1 )
233 cout <<
"ADJ_INSERT_IJ - Fatal error!\n";
234 cout <<
" All available storage has been used.\n";
235 cout <<
" No more information can be stored!\n";
236 cout <<
" This error occurred for \n";
237 cout <<
" Row I = " << i <<
"\n";
238 cout <<
" Column J = " << j <<
"\n";
244 j_spot = adj_row[i-1];
246 for ( k = adj_row[i-1]; k <= adj_row[i]-1; k++ )
252 else if ( adj[k-1] < j )
262 for ( k = *adj_num; j_spot <= k; k-- )
268 for ( k = i; k <= node_num; k++ )
270 adj_row[k] = adj_row[k] + 1;
273 *adj_num = *adj_num + 1;
280 int perm[],
int perm_inv[] )
341 for ( i = 0; i < node_num; i++ )
343 for ( j = adj_row[perm[i]-1]; j <= adj_row[perm[i]]-1; j++ )
345 col = perm_inv[adj[j-1]-1];
346 band_lo =
i4_max ( band_lo, i - col );
347 band_hi =
i4_max ( band_hi, col - i );
351 bandwidth = band_lo + 1 + band_hi;
358 int perm[],
int perm_inv[] )
417 band =
new char[node_num];
423 cout <<
" Nonzero structure of matrix:\n";
426 for ( i = 0; i < node_num; i++ )
428 for ( k = 0; k < node_num; k++ )
435 for ( j = adj_row[perm[i]-1]; j <= adj_row[perm[i]]-1; j++ )
437 col = perm_inv[adj[j-1]-1] - 1;
441 nonzero_num = nonzero_num + 1;
444 band_lo =
i4_max ( band_lo, i - col );
451 cout <<
" " << setw(8) << i + 1 <<
" ";
452 for ( j = 0; j < node_num; j++ )
460 cout <<
" Lower bandwidth = " << band_lo <<
"\n";
461 cout <<
" Lower envelope contains " << nonzero_num <<
" nonzeros.\n";
468 void adj_print (
int node_num,
int adj_num,
int adj_row[],
int adj[],
516 adj_print_some ( node_num, 1, node_num, adj_num, adj_row, adj, title );
523 int adj_row[],
int adj[],
string title )
581 cout << title <<
"\n";
583 cout <<
" Sparse adjacency structure:\n";
585 cout <<
" Number of nodes = " << node_num <<
"\n";
586 cout <<
" Number of adjacencies = " << adj_num <<
"\n";
588 cout <<
" Node Min Max Nonzeros \n";
591 for ( i = node_lo; i <= node_hi; i++ )
594 jmax = adj_row[i] - 1;
598 cout <<
" " << setw(4) << i
599 <<
" " << setw(4) << jmin
600 <<
" " << setw(4) << jmax <<
"\n";
604 for ( jlo = jmin; jlo <= jmax; jlo = jlo + 5 )
606 jhi =
i4_min ( jlo + 4, jmax );
610 cout <<
" " << setw(4) << i
611 <<
" " << setw(4) << jmin
612 <<
" " << setw(4) << jmax
614 for ( j = jlo; j <= jhi; j++ )
616 cout << setw(8) << adj[j-1];
623 for ( j = jlo; j <= jhi; j++ )
625 cout << setw(8) << adj[j-1];
637 void adj_set (
int node_num,
int adj_max,
int *adj_num,
int adj_row[],
638 int adj[],
int irow,
int jcol )
700 if ( irow < 0 || jcol < 0 )
703 cout <<
"ADJ_SET - Note:\n";
704 cout <<
" Initializing adjacency information.\n";
705 cout <<
" Number of nodes NODE_NUM = " << node_num <<
"\n";
706 cout <<
" Maximum adjacency ADJ_MAX = " << adj_max <<
"\n";
709 for ( i = 0; i < node_num + 1; i++ )
713 for ( i = 0; i < adj_max; i++ )
727 if ( node_num < irow )
730 cout <<
"ADJ_SET - Fatal error!\n";
731 cout <<
" NODE_NUM < IROW.\n";
732 cout <<
" IROW = " << irow <<
"\n";
733 cout <<
" NODE_NUM = " << node_num <<
"\n";
739 cout <<
"ADJ_SET - Fatal error!\n";
740 cout <<
" IROW < 1.\n";
741 cout <<
" IROW = " << irow <<
"\n";
744 else if ( node_num < jcol )
747 cout <<
"ADJ_SET - Fatal error!\n";
748 cout <<
" NODE_NUM < JCOL.\n";
749 cout <<
" JCOL = " << jcol <<
"\n";
750 cout <<
" NODE_NUM = " << node_num <<
"\n";
756 cout <<
"ADJ_SET - Fatal error!\n";
757 cout <<
" JCOL < 1.\n";
758 cout <<
" JCOL = " << jcol <<
"\n";
762 if ( !
adj_contains_ij ( node_num, *adj_num, adj_row, adj, irow, jcol ) )
764 adj_insert_ij ( node_num, adj_max, adj_num, adj_row, adj, irow, jcol );
767 if ( !
adj_contains_ij ( node_num, *adj_num, adj_row, adj, jcol, irow ) )
769 adj_insert_ij ( node_num, adj_max, adj_num, adj_row, adj, jcol, irow );
776 void adj_show (
int node_num,
int adj_num,
int adj_row[],
int adj[] )
829 band =
new char[node_num];
835 cout <<
" Nonzero structure of matrix:\n";
838 for ( i = 0; i < node_num; i++ )
840 for ( k = 0; k < node_num; k++ )
847 for ( j = adj_row[i]; j <= adj_row[i+1]-1; j++ )
852 nonzero_num = nonzero_num + 1;
854 band_lo = max ( band_lo, i - col );
857 cout <<
" " << setw(8) << i + 1 <<
" ";
858 for ( j = 0; j < node_num; j++ )
866 cout <<
" Lower bandwidth = " << band_lo <<
"\n";
867 cout <<
" Lower envelope contains " << nonzero_num <<
" nonzeros.\n";
875 void degree (
int root,
int adj_num,
int adj_row[],
int adj[],
int mask[],
876 int deg[],
int *iccsze,
int ls[],
int node_num )
949 adj_row[root-1] = -adj_row[root-1];
964 for ( i = lbegin; i <= lvlend; i++ )
967 jstrt = -adj_row[node-1];
968 jstop =
abs ( adj_row[node] ) - 1;
971 for ( j = jstrt; j <= jstop; j++ )
975 if ( mask[nbr-1] != 0 )
979 if ( 0 <= adj_row[nbr-1] )
981 adj_row[nbr-1] = -adj_row[nbr-1];
982 *iccsze = *iccsze + 1;
992 lvsize = *iccsze - lvlend;
1004 for ( i = 0; i < *iccsze; i++ )
1007 adj_row[node] = -adj_row[node];
1014 void genrcm (
int node_num,
int adj_num,
int adj_row[],
int adj[],
int perm[] )
1077 level_row =
new int[node_num+1];
1078 mask =
new int[node_num];
1080 for ( i = 0; i < node_num; i++ )
1087 for ( i = 0; i < node_num; i++ )
1099 root_find ( &root, adj_num, adj_row, adj, mask, &level_num,
1100 level_row, perm+num-1, node_num );
1104 rcm ( root, adj_num, adj_row, adj, mask, perm+num-1, &iccsze,
1111 if ( node_num < num )
1113 delete [] level_row;
1120 delete [] level_row;
1165 # define NODE_NUM 10 1167 static int adj_save[
ADJ_NUM] = {
1178 static int adj_row_save[
NODE_NUM+1] = {
1179 1, 3, 7, 10, 14, 17, 21, 25, 27, 28, 29
1183 for ( i = 0; i <
ADJ_NUM; i++ )
1185 adj[i] = adj_save[i];
1188 for ( i = 0; i <
NODE_NUM + 1; i++ )
1190 adj_row[i] = adj_row_save[i];
1458 cerr <<
"I4_UNIFORM - Fatal error!\n";
1459 cerr <<
" Input value of SEED = 0.\n";
1465 *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
1469 *seed = *seed + 2147483647;
1472 r = ( float ) ( *seed ) * 4.656612875E-10;
1476 r = ( 1.0 - r ) * ( (
float ) (
i4_min ( a, b ) ) - 0.5 )
1477 + r * ( ( float ) (
i4_max ( a, b ) ) + 0.5 );
1547 cout <<
"I4COL_COMPARE - Fatal error!\n";
1548 cout <<
" Column index I = " << i <<
" is less than 1.\n";
1555 cout <<
"I4COL_COMPARE - Fatal error!\n";
1556 cout <<
" N = " << n <<
" is less than column index I = " << i <<
".\n";
1563 cout <<
"I4COL_COMPARE - Fatal error!\n";
1564 cout <<
" Column index J = " << j <<
" is less than 1.\n";
1571 cout <<
"I4COL_COMPARE - Fatal error!\n";
1572 cout <<
" N = " << n <<
" is less than column index J = " << j <<
".\n";
1585 if ( a[k-1+(i-1)*m] < a[k-1+(j-1)*m] )
1589 else if ( a[k-1+(j-1)*m] < a[k-1+(i-1)*m] )
1672 else if ( indx < 0 )
1676 else if ( indx == 0 )
1736 cout <<
"I4COL_SWAP - Fatal error!\n";
1737 cout <<
" ICOL1 is out of range.\n";
1744 cout <<
"I4COL_SWAP - Fatal error!\n";
1745 cout <<
" ICOL2 is out of range.\n";
1749 if ( icol1 == icol2 )
1753 for ( i = 0; i <
m; i++ )
1755 t = a[i+(icol1-
OFFSET)*m];
1757 a[i+(icol2-
OFFSET)*m] = t;
1766 int jhi,
string title )
1811 cout << title <<
"\n";
1815 for ( j2lo = jlo; j2lo <= jhi; j2lo = j2lo +
INCX )
1817 j2hi = j2lo +
INCX - 1;
1818 j2hi =
i4_min ( j2hi, n );
1819 j2hi =
i4_min ( j2hi, jhi );
1828 for ( j = j2lo; j <= j2hi; j++ )
1830 cout << setw(6) << j <<
" ";
1838 i2lo =
i4_max ( ilo, 1 );
1839 i2hi =
i4_min ( ihi, m );
1841 for ( i = i2lo; i <= i2hi; i++ )
1846 cout << setw(5) << i <<
" ";
1847 for ( j = j2lo; j <= j2hi; j++ )
1849 cout << setw(6) << a[i-1+(j-1)*m] <<
" ";
1902 int ihi,
int jhi,
string title )
1947 cout << title <<
"\n";
1951 for ( i2lo = ilo; i2lo <= ihi; i2lo = i2lo +
INCX )
1953 i2hi = i2lo +
INCX - 1;
1954 i2hi =
i4_min ( i2hi, m );
1955 i2hi =
i4_min ( i2hi, ihi );
1964 for ( i = i2lo; i <= i2hi; i++ )
1966 cout << setw(6) << i <<
" ";
1974 j2lo =
i4_max ( jlo, 1 );
1975 j2hi =
i4_min ( jhi, n );
1977 for ( j = j2lo; j <= j2hi; j++ )
1982 cout << setw(5) << j <<
" ";
1983 for ( i = i2lo; i <= i2hi; i++ )
1985 cout << setw(6) << a[i-1+(j-1)*m] <<
" ";
2058 for ( i = (n/2)-1; 0 <= i; i-- )
2092 if ( a[m] < a[m+1] )
2159 for ( i = 0; i < n; i++ )
2200 cout << title <<
"\n";
2202 for ( i = 0; i <= n-1; i++ )
2204 cout <<
" " << setw(8) << i + 1
2205 <<
" " << setw(8) << a[i] <<
"\n";
2253 for ( i = 0; i < n / 2; i++ )
2323 for ( n1 = n-1; 2 <= n1; n1-- )
2341 void level_set (
int root,
int adj_num,
int adj_row[],
int adj[],
int mask[],
2342 int *level_num,
int level_row[],
int level[],
int node_num )
2428 lbegin = lvlend + 1;
2430 *level_num = *level_num + 1;
2431 level_row[*level_num-1] = lbegin;
2436 for ( i = lbegin; i <= lvlend; i++ )
2439 jstrt = adj_row[node-1];
2440 jstop = adj_row[node] - 1;
2442 for ( j = jstrt; j <= jstop; j++ )
2446 if ( mask[nbr-1] != 0 )
2448 iccsze = iccsze + 1;
2449 level[iccsze-1] = nbr;
2458 lvsize = iccsze - lvlend;
2466 level_row[*level_num] = lvlend + 1;
2470 for ( i = 0; i < iccsze; i++ )
2472 mask[level[i]-1] = 1;
2522 cout <<
"LEVEL_SET_PRINT\n";
2523 cout <<
" Show the level set structure of a rooted graph.\n";
2524 cout <<
" The number of nodes is " << node_num <<
"\n";
2525 cout <<
" The number of levels is " << level_num <<
"\n";
2527 cout <<
" Level Min Max Nonzeros\n";
2530 for ( i = 0; i < level_num; i++ )
2532 jmin = level_row[i];
2533 jmax = level_row[i+1] - 1;
2537 cout <<
" " << setw(4) << i+1
2538 <<
" " << setw(4) << jmin
2539 <<
" " << setw(4) << jmax <<
"\n";
2543 for ( jlo = jmin; jlo <= jmax; jlo = jlo + 5 )
2545 jhi =
i4_min ( jlo + 4, jmax );
2549 cout <<
" " << setw(4) << i+1
2550 <<
" " << setw(4) << jmin
2551 <<
" " << setw(4) << jmax
2553 for ( j = jlo; j <= jhi; j++ )
2555 cout << setw(8) << level[j-1];
2562 for ( j = jlo; j <= jhi; j++ )
2564 cout << setw(8) << level[j-1];
2615 for ( seek = 1; seek <= n; seek++ )
2619 for ( i = 0; i < n; i++ )
2670 for ( i = 0; i < n; i++ )
2672 perm_inv[perm[i]-1] = i + 1;
2721 for ( i = 1; i <= n; i++ )
2726 for ( i = 1; i <= n; i++ )
2821 value = - ( int ) (
r4_abs ( x ) + 0.5 );
2825 value = ( int ) (
r4_abs ( x ) + 0.5 );
2901 cout <<
"R82VEC_PERMUTE - Fatal error!\n";
2902 cout <<
" The input array does not represent\n";
2903 cout <<
" a proper permutation.\n";
2910 for ( istart = 1; istart <= n; istart++ )
2912 if ( p[istart-1] < 0 )
2916 else if ( p[istart-1] == istart )
2918 p[istart-1] = -p[istart-1];
2923 a_temp[0] = a[0+(istart-1)*2];
2924 a_temp[1] = a[1+(istart-1)*2];
2934 p[iput-1] = -p[iput-1];
2936 if ( iget < 1 || n < iget )
2939 cout <<
"R82VEC_PERMUTE - Fatal error!\n";
2940 cout <<
" Entry IPUT = " << iput <<
" of the permutation has\n";
2941 cout <<
" an illegal value IGET = " << iget <<
".\n";
2945 if ( iget == istart )
2947 a[0+(iput-1)*2] = a_temp[0];
2948 a[1+(iput-1)*2] = a_temp[1];
2951 a[0+(iput-1)*2] = a[0+(iget-1)*2];
2952 a[1+(iput-1)*2] = a[1+(iget-1)*2];
2959 for ( i = 0; i < n; i++ )
2969 int jhi,
string title )
3014 cout << title <<
"\n";
3018 for ( j2lo = jlo; j2lo <= jhi; j2lo = j2lo +
INCX )
3020 j2hi = j2lo +
INCX - 1;
3021 j2hi =
i4_min ( j2hi, n );
3022 j2hi =
i4_min ( j2hi, jhi );
3031 for ( j = j2lo; j <= j2hi; j++ )
3033 cout << setw(7) << j <<
" ";
3041 i2lo =
i4_max ( ilo, 1 );
3042 i2hi =
i4_min ( ihi, m );
3044 for ( i = i2lo; i <= i2hi; i++ )
3049 cout << setw(5) << i <<
" ";
3050 for ( j = j2lo; j <= j2hi; j++ )
3052 cout << setw(12) << a[i-1+(j-1)*m] <<
" ";
3067 int ihi,
int jhi,
string title )
3112 cout << title <<
"\n";
3114 for ( i2lo =
i4_max ( ilo, 1 ); i2lo <=
i4_min ( ihi, m ); i2lo = i2lo +
INCX )
3116 i2hi = i2lo +
INCX - 1;
3117 i2hi =
i4_min ( i2hi, m );
3118 i2hi =
i4_min ( i2hi, ihi );
3120 inc = i2hi + 1 - i2lo;
3124 for ( i = i2lo; i <= i2hi; i++ )
3126 cout << setw(7) << i <<
" ";
3132 j2lo =
i4_max ( jlo, 1 );
3133 j2hi =
i4_min ( jhi, n );
3135 for ( j = j2lo; j <= j2hi; j++ )
3137 cout << setw(5) << j <<
" ";
3138 for ( i2 = 1; i2 <= inc; i2++ )
3141 cout << setw(14) << a[(i-1)+(j-1)*
m];
3153 void rcm (
int root,
int adj_num,
int adj_row[],
int adj[],
int mask[],
3154 int perm[],
int *iccsze,
int node_num )
3244 deg =
new int[node_num];
3246 degree ( root, adj_num, adj_row, adj, mask, deg, iccsze, perm, node_num );
3262 while ( lvlend < lnbr )
3264 lbegin = lvlend + 1;
3267 for ( i = lbegin; i <= lvlend; i++ )
3273 jstrt = adj_row[node-1];
3274 jstop = adj_row[node] - 1;
3283 for ( j = jstrt; j <= jstop; j++ )
3287 if ( mask[nbr-1] != 0 )
3317 if ( deg[lperm-1] <= deg[nbr-1] )
3340 void root_find (
int *root,
int adj_num,
int adj_row[],
int adj[],
int mask[],
3341 int *level_num,
int level_row[],
int level[],
int node_num )
3445 level_set ( *root, adj_num, adj_row, adj, mask, level_num,
3446 level_row, level, node_num );
3450 iccsze = level_row[*level_num] - 1;
3456 if ( *level_num == 1 )
3465 if ( *level_num == iccsze )
3477 jstrt = level_row[*level_num-1];
3478 *root = level[jstrt-1];
3480 if ( jstrt < iccsze )
3482 for ( j = jstrt; j <= iccsze; j++ )
3486 kstrt = adj_row[node-1];
3487 kstop = adj_row[node] - 1;
3489 for ( k = kstrt; k <= kstop; k++ )
3492 if ( 0 < mask[nabor-1] )
3498 if ( ndeg < mindeg )
3508 level_set ( *root, adj_num, adj_row, adj, mask, &level_num2,
3509 level_row, level, node_num );
3513 if ( level_num2 <= *level_num )
3518 *level_num = level_num2;
3523 if ( iccsze <= *level_num )
3589 static int i_save = 0;
3590 static int j_save = 0;
3609 else if ( *indx < 0 )
3615 i_save = i_save + 1;
3660 else if ( *indx == 1 )
3679 else if ( i_save <= n1 )
3681 j_save = i_save + 1;
3748 # define TIME_SIZE 40 3751 const struct tm *tm;
3755 now = time ( NULL );
3756 tm = localtime ( &now );
3758 len = strftime ( time_buffer,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
3760 cout << time_buffer <<
"\n";
3768 int triangle_node[] )
3876 int *triangle_neighbor;
3878 triangle_neighbor =
new int[3*triangle_num];
3879 col =
new int[4*(3*triangle_num)];
3891 for ( tri = 0; tri < triangle_num; tri++ )
3893 i = triangle_node[0+tri*triangle_order];
3894 j = triangle_node[1+tri*triangle_order];
3895 k = triangle_node[2+tri*triangle_order];
3899 col[0+(3*tri+0)*4] = i;
3900 col[1+(3*tri+0)*4] = j;
3901 col[2+(3*tri+0)*4] = 3;
3902 col[3+(3*tri+0)*4] = tri + 1;
3906 col[0+(3*tri+0)*4] = j;
3907 col[1+(3*tri+0)*4] = i;
3908 col[2+(3*tri+0)*4] = 3;
3909 col[3+(3*tri+0)*4] = tri + 1;
3914 col[0+(3*tri+1)*4] = j;
3915 col[1+(3*tri+1)*4] = k;
3916 col[2+(3*tri+1)*4] = 1;
3917 col[3+(3*tri+1)*4] = tri + 1;
3921 col[0+(3*tri+1)*4] = k;
3922 col[1+(3*tri+1)*4] = j;
3923 col[2+(3*tri+1)*4] = 1;
3924 col[3+(3*tri+1)*4] = tri + 1;
3929 col[0+(3*tri+2)*4] = k;
3930 col[1+(3*tri+2)*4] = i;
3931 col[2+(3*tri+2)*4] = 2;
3932 col[3+(3*tri+2)*4] = tri + 1;
3936 col[0+(3*tri+2)*4] = i;
3937 col[1+(3*tri+2)*4] = k;
3938 col[2+(3*tri+2)*4] = 2;
3939 col[3+(3*tri+2)*4] = tri + 1;
3959 for ( j = 0; j < triangle_num; j++ )
3961 for ( i = 0; i < 3; i++ )
3963 triangle_neighbor[i+j*3] = -1;
3971 if ( 3 * triangle_num <= icol )
3976 if ( col[0+(icol-1)*4] != col[0+icol*4] ||
3977 col[1+(icol-1)*4] != col[1+icol*4] )
3983 side1 = col[2+(icol-1)*4];
3984 tri1 = col[3+(icol-1)*4];
3985 side2 = col[2+ icol *4];
3986 tri2 = col[3+ icol *4];
3988 triangle_neighbor[side1-1+(tri1-1)*3] = tri2;
3989 triangle_neighbor[side2-1+(tri2-1)*3] = tri1;
3996 return triangle_neighbor;
4001 int triangle_node[],
int triangle_neighbor[],
int adj_col[] )
4132 int triangle_order = 3;
4139 for ( node = 0; node < node_num; node++ )
4146 for ( triangle = 0; triangle < triangle_num; triangle++ )
4148 n1 = triangle_node[0+triangle*triangle_order];
4149 n2 = triangle_node[1+triangle*triangle_order];
4150 n3 = triangle_node[2+triangle*triangle_order];
4157 triangle2 = triangle_neighbor[0+triangle*3];
4159 if ( triangle2 < 0 || triangle < triangle2 )
4161 adj_col[n1-1] = adj_col[n1-1] + 1;
4162 adj_col[n2-1] = adj_col[n2-1] + 1;
4167 triangle2 = triangle_neighbor[1+triangle*3];
4169 if ( triangle2 < 0 || triangle < triangle2 )
4171 adj_col[n2-1] = adj_col[n2-1] + 1;
4172 adj_col[n3-1] = adj_col[n3-1] + 1;
4177 triangle2 = triangle_neighbor[2+triangle*3];
4179 if ( triangle2 < 0 || triangle < triangle2 )
4181 adj_col[n1-1] = adj_col[n1-1] + 1;
4182 adj_col[n3-1] = adj_col[n3-1] + 1;
4189 for ( node = node_num; 1 <= node; node-- )
4191 adj_col[node] = adj_col[node-1];
4194 for ( i = 1; i <= node_num; i++ )
4196 adj_col[i]= adj_col[i-1] + adj_col[i];
4199 adj_num = adj_col[node_num] - 1;
4206 int triangle_node[],
int triangle_neighbor[],
int adj_num,
int adj_col[] )
4348 int triangle_order = 3;
4350 adj =
new int[adj_num];
4351 for ( k = 0; k < adj_num; k++ )
4356 adj_copy =
new int[node_num];
4357 for ( node = 0; node < node_num; node++ )
4359 adj_copy[node] = adj_col[node];
4364 for ( node = 1; node <= node_num; node++ )
4366 adj[adj_copy[node-1]-1] = node;
4367 adj_copy[node-1] = adj_copy[node-1] + 1;
4372 for ( triangle = 0; triangle < triangle_num; triangle++ )
4374 n1 = triangle_node[0+triangle*triangle_order];
4375 n2 = triangle_node[1+triangle*triangle_order];
4376 n3 = triangle_node[2+triangle*triangle_order];
4383 triangle2 = triangle_neighbor[0+triangle*3];
4385 if ( triangle2 < 0 || triangle < triangle2 )
4387 adj[adj_copy[n1-1]-1] = n2;
4388 adj_copy[n1-1] = adj_copy[n1-1] + 1;
4389 adj[adj_copy[n2-1]-1] = n1;
4390 adj_copy[n2-1] = adj_copy[n2-1] + 1;
4395 triangle2 = triangle_neighbor[1+triangle*3];
4397 if ( triangle2 < 0 || triangle < triangle2 )
4399 adj[adj_copy[n2-1]-1] = n3;
4400 adj_copy[n2-1] = adj_copy[n2-1] + 1;
4401 adj[adj_copy[n3-1]-1] = n2;
4402 adj_copy[n3-1] = adj_copy[n3-1] + 1;
4407 triangle2 = triangle_neighbor[2+triangle*3];
4409 if ( triangle2 < 0 || triangle < triangle2 )
4411 adj[adj_copy[n1-1]-1] = n3;
4412 adj_copy[n1-1] = adj_copy[n1-1] + 1;
4413 adj[adj_copy[n3-1]-1] = n1;
4414 adj_copy[n3-1] = adj_copy[n3-1] + 1;
4420 for ( node = 1; node <= node_num; node++ )
4422 k1 = adj_col[node-1];
4423 k2 = adj_col[node]-1;
4434 double node_xy[],
int triangle_node[],
int triangle_neighbor[] )
4492 # define NODE_NUM 25 4493 # define TRIANGLE_NUM 32 4494 # define TRIANGLE_ORDER 3 4592 triangle_neighbor[i] = triangle_neighbor_save[i];
4597 triangle_node[i] = triangle_node_save[i];
4602 node_xy[i] = node_xy_save[i];
4608 # undef TRIANGLE_NUM 4609 # undef TRIANGLE_ORDER 4668 int triangle_node[],
int triangle_neighbor[],
int adj_col[] )
4834 int triangle_order = 6;
4841 for ( node = 0; node < node_num; node++ )
4848 for ( triangle = 0; triangle < triangle_num; triangle++ )
4850 n1 = triangle_node[0+triangle*triangle_order];
4851 n2 = triangle_node[1+triangle*triangle_order];
4852 n3 = triangle_node[2+triangle*triangle_order];
4853 n4 = triangle_node[3+triangle*triangle_order];
4854 n5 = triangle_node[4+triangle*triangle_order];
4855 n6 = triangle_node[5+triangle*triangle_order];
4865 adj_col[n3-1] = adj_col[n3-1] + 1;
4866 adj_col[n4-1] = adj_col[n4-1] + 1;
4867 adj_col[n1-1] = adj_col[n1-1] + 1;
4868 adj_col[n5-1] = adj_col[n5-1] + 1;
4869 adj_col[n4-1] = adj_col[n4-1] + 1;
4870 adj_col[n5-1] = adj_col[n5-1] + 1;
4871 adj_col[n2-1] = adj_col[n2-1] + 1;
4872 adj_col[n6-1] = adj_col[n6-1] + 1;
4873 adj_col[n4-1] = adj_col[n4-1] + 1;
4874 adj_col[n6-1] = adj_col[n6-1] + 1;
4875 adj_col[n5-1] = adj_col[n5-1] + 1;
4876 adj_col[n6-1] = adj_col[n6-1] + 1;
4888 triangle2 = triangle_neighbor[0+triangle*3];
4890 if ( triangle2 < 0 || triangle < triangle2 )
4892 adj_col[n1-1] = adj_col[n1-1] + 1;
4893 adj_col[n2-1] = adj_col[n2-1] + 1;
4894 adj_col[n1-1] = adj_col[n1-1] + 1;
4895 adj_col[n4-1] = adj_col[n4-1] + 1;
4896 adj_col[n2-1] = adj_col[n2-1] + 1;
4897 adj_col[n4-1] = adj_col[n4-1] + 1;
4905 triangle2 = triangle_neighbor[1+triangle*3];
4907 if ( triangle2 < 0 || triangle < triangle2 )
4909 adj_col[n2-1] = adj_col[n2-1] + 1;
4910 adj_col[n3-1] = adj_col[n3-1] + 1;
4911 adj_col[n2-1] = adj_col[n2-1] + 1;
4912 adj_col[n5-1] = adj_col[n5-1] + 1;
4913 adj_col[n3-1] = adj_col[n3-1] + 1;
4914 adj_col[n5-1] = adj_col[n5-1] + 1;
4922 triangle2 = triangle_neighbor[2+triangle*3];
4924 if ( triangle2 < 0 || triangle < triangle2 )
4926 adj_col[n1-1] = adj_col[n1-1] + 1;
4927 adj_col[n3-1] = adj_col[n3-1] + 1;
4928 adj_col[n1-1] = adj_col[n1-1] + 1;
4929 adj_col[n6-1] = adj_col[n6-1] + 1;
4930 adj_col[n3-1] = adj_col[n3-1] + 1;
4931 adj_col[n6-1] = adj_col[n6-1] + 1;
4938 for ( node = node_num; 1 <= node; node-- )
4940 adj_col[node] = adj_col[node-1];
4943 for ( i = 1; i <= node_num; i++ )
4945 adj_col[i]= adj_col[i-1] + adj_col[i];
4948 adj_num = adj_col[node_num] - 1;
4955 int triangle_node[],
int triangle_neighbor[],
int adj_num,
int adj_col[] )
5132 int triangle_order = 6;
5134 adj =
new int[adj_num];
5135 for ( k = 0; k < adj_num; k++ )
5140 adj_copy =
new int[node_num];
5141 for ( node = 0; node < node_num; node++ )
5143 adj_copy[node] = adj_col[node];
5148 for ( node = 1; node <= node_num; node++ )
5150 adj[adj_copy[node-1]-1] = node;
5151 adj_copy[node-1] = adj_copy[node-1] + 1;
5156 for ( triangle = 0; triangle < triangle_num; triangle++ )
5158 n1 = triangle_node[0+triangle*triangle_order];
5159 n2 = triangle_node[1+triangle*triangle_order];
5160 n3 = triangle_node[2+triangle*triangle_order];
5161 n4 = triangle_node[3+triangle*triangle_order];
5162 n5 = triangle_node[4+triangle*triangle_order];
5163 n6 = triangle_node[5+triangle*triangle_order];
5173 adj[adj_copy[n3-1]-1] = n4;
5174 adj_copy[n3-1] = adj_copy[n3-1] + 1;
5175 adj[adj_copy[n4-1]-1] = n3;
5176 adj_copy[n4-1] = adj_copy[n4-1] + 1;
5178 adj[adj_copy[n1-1]-1] = n5;
5179 adj_copy[n1-1] = adj_copy[n1-1] + 1;
5180 adj[adj_copy[n5-1]-1] = n1;
5181 adj_copy[n5-1] = adj_copy[n5-1] + 1;
5183 adj[adj_copy[n4-1]-1] = n5;
5184 adj_copy[n4-1] = adj_copy[n4-1] + 1;
5185 adj[adj_copy[n5-1]-1] = n4;
5186 adj_copy[n5-1] = adj_copy[n5-1] + 1;
5188 adj[adj_copy[n2-1]-1] = n6;
5189 adj_copy[n2-1] = adj_copy[n2-1] + 1;
5190 adj[adj_copy[n6-1]-1] = n2;
5191 adj_copy[n6-1] = adj_copy[n6-1] + 1;
5193 adj[adj_copy[n4-1]-1] = n6;
5194 adj_copy[n4-1] = adj_copy[n4-1] + 1;
5195 adj[adj_copy[n6-1]-1] = n4;
5196 adj_copy[n6-1] = adj_copy[n6-1] + 1;
5198 adj[adj_copy[n5-1]-1] = n6;
5199 adj_copy[n5-1] = adj_copy[n5-1] + 1;
5200 adj[adj_copy[n6-1]-1] = n5;
5201 adj_copy[n6-1] = adj_copy[n6-1] + 1;
5213 triangle2 = triangle_neighbor[0+triangle*3];
5215 if ( triangle2 < 0 || triangle < triangle2 )
5217 adj[adj_copy[n1-1]-1] = n2;
5218 adj_copy[n1-1] = adj_copy[n1-1] + 1;
5219 adj[adj_copy[n2-1]-1] = n1;
5220 adj_copy[n2-1] = adj_copy[n2-1] + 1;
5221 adj[adj_copy[n1-1]-1] = n4;
5222 adj_copy[n1-1] = adj_copy[n1-1] + 1;
5223 adj[adj_copy[n4-1]-1] = n1;
5224 adj_copy[n4-1] = adj_copy[n4-1] + 1;
5225 adj[adj_copy[n2-1]-1] = n4;
5226 adj_copy[n2-1] = adj_copy[n2-1] + 1;
5227 adj[adj_copy[n4-1]-1] = n2;
5228 adj_copy[n4-1] = adj_copy[n4-1] + 1;
5236 triangle2 = triangle_neighbor[1+triangle*3];
5238 if ( triangle2 < 0 || triangle < triangle2 )
5240 adj[adj_copy[n2-1]-1] = n3;
5241 adj_copy[n2-1] = adj_copy[n2-1] + 1;
5242 adj[adj_copy[n3-1]-1] = n2;
5243 adj_copy[n3-1] = adj_copy[n3-1] + 1;
5244 adj[adj_copy[n2-1]-1] = n5;
5245 adj_copy[n2-1] = adj_copy[n2-1] + 1;
5246 adj[adj_copy[n5-1]-1] = n2;
5247 adj_copy[n5-1] = adj_copy[n5-1] + 1;
5248 adj[adj_copy[n3-1]-1] = n5;
5249 adj_copy[n3-1] = adj_copy[n3-1] + 1;
5250 adj[adj_copy[n5-1]-1] = n3;
5251 adj_copy[n5-1] = adj_copy[n5-1] + 1;
5259 triangle2 = triangle_neighbor[2+triangle*3];
5261 if ( triangle2 < 0 || triangle < triangle2 )
5263 adj[adj_copy[n1-1]-1] = n3;
5264 adj_copy[n1-1] = adj_copy[n1-1] + 1;
5265 adj[adj_copy[n3-1]-1] = n1;
5266 adj_copy[n3-1] = adj_copy[n3-1] + 1;
5267 adj[adj_copy[n1-1]-1] = n6;
5268 adj_copy[n1-1] = adj_copy[n1-1] + 1;
5269 adj[adj_copy[n6-1]-1] = n1;
5270 adj_copy[n6-1] = adj_copy[n6-1] + 1;
5271 adj[adj_copy[n3-1]-1] = n6;
5272 adj_copy[n3-1] = adj_copy[n3-1] + 1;
5273 adj[adj_copy[n6-1]-1] = n3;
5274 adj_copy[n6-1] = adj_copy[n6-1] + 1;
5280 for ( node = 1; node <= node_num; node++ )
5282 k1 = adj_col[node-1];
5283 k2 = adj_col[node]-1;
5294 double node_xy[],
int triangle_node[],
int triangle_neighbor[] )
5353 # define NODE_NUM 25 5354 # define TRIANGLE_NUM 8 5355 # define TRIANGLE_ORDER 6 5387 13, 11, 3, 12, 7, 8,
5389 15, 13, 5, 14, 9, 10,
5390 11, 13, 21, 12, 17, 16,
5391 23, 21, 13, 22, 17, 18,
5392 13, 15, 23, 14, 19, 18,
5393 25, 23, 15, 24, 19, 20 };
5406 for ( i = 0; i <
DIM_NUM; i++ )
5422 for ( i = 0; i < 3; i++ )
5424 triangle_neighbor[i+j*3] = triangle_neighbor_save[i+j*3];
5431 # undef TRIANGLE_NUM 5432 # undef TRIANGLE_ORDER int triangulation_order3_adj_count(int node_num, int triangle_num, int triangle_node[], int triangle_neighbor[], int adj_col[])
int * triangulation_order6_adj_set(int node_num, int triangle_num, int triangle_node[], int triangle_neighbor[], int adj_num, int adj_col[])
void level_set_print(int node_num, int level_num, int level_row[], int level[])
int i4_max(int i1, int i2)
int adj_perm_bandwidth(int node_num, int adj_num, int adj_row[], int adj[], int perm[], int perm_inv[])
void r8mat_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title)
int * triangulation_order3_adj_set(int node_num, int triangle_num, int triangle_node[], int triangle_neighbor[], int adj_num, int adj_col[])
int * perm_uniform(int n, int *seed)
void triangulation_order6_example2(int node_num, int triangle_num, double node_xy[], int triangle_node[], int triangle_neighbor[])
void i4vec_print(int n, int a[], string title)
void r82vec_permute(int n, double a[], int p[])
void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num)
void adj_insert_ij(int node_num, int adj_max, int *adj_num, int adj_row[], int adj[], int i, int j)
int * i4vec_indicator(int n)
int i4col_compare(int m, int n, int a[], int i, int j)
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
int adj_bandwidth(int node_num, int adj_num, int adj_row[], int adj[])
void perm_inverse3(int n, int perm[], int perm_inv[])
void i4vec_reverse(int n, int a[])
void adj_show(int node_num, int adj_num, int adj_row[], int adj[])
bool adj_contains_ij(int node_num, int adj_num, int adj_row[], int adj[], int i, int j)
void i4col_swap(int m, int n, int a[], int icol1, int icol2)
void root_find(int *root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num)
void level_set(int root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num)
void graph_01_size(int *node_num, int *adj_num)
void i4mat_print_some(int m, int n, int a[], int ilo, int jlo, int ihi, int jhi, string title)
void i4col_sort_a(int m, int n, int a[])
void i4mat_transpose_print_some(int m, int n, int a[], int ilo, int jlo, int ihi, int jhi, string title)
void triangulation_order6_example2_size(int *node_num, int *triangle_num, int *hole_num)
void i4_swap(int *i, int *j)
void i4mat_transpose_print(int m, int n, int a[], string title)
void triangulation_order3_example2_size(int *node_num, int *triangle_num, int *hole_num)
void i4vec_sort_heap_a(int n, int a[])
void adj_set(int node_num, int adj_max, int *adj_num, int adj_row[], int adj[], int irow, int jcol)
void adj_perm_show(int node_num, int adj_num, int adj_row[], int adj[], int perm[], int perm_inv[])
bool perm_check(int n, int p[])
void r8mat_transpose_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title)
void genrcm(int node_num, int adj_num, int adj_row[], int adj[], int perm[])
void i4vec_heap_d(int n, int a[])
void sort_heap_external(int n, int *indx, int *i, int *j, int isgn)
int i4_uniform(int a, int b, int *seed)
int triangulation_order6_adj_count(int node_num, int triangle_num, int triangle_node[], int triangle_neighbor[], int adj_col[])
void adj_print_some(int node_num, int node_lo, int node_hi, int adj_num, int adj_row[], int adj[], string title)
void rcm(int root, int adj_num, int adj_row[], int adj[], int mask[], int perm[], int *iccsze, int node_num)
void graph_01_adj(int node_num, int adj_num, int adj_row[], int adj[])
void triangulation_order3_example2(int node_num, int triangle_num, double node_xy[], int triangle_node[], int triangle_neighbor[])
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
int * triangulation_neighbor_triangles(int triangle_order, int triangle_num, int triangle_node[])
int i4_min(int i1, int i2)
void adj_print(int node_num, int adj_num, int adj_row[], int adj[], string title)