void country_graph_coloring(int seed, SparseMatrix A, int **p, real *norm_1){
country_graph_coloring_internal(seed, A, p, norm_1, DO_SWAPPING);
}
-
-void improve_antibandwidth_by_swapping_for_fortran(int *n, int *nz, int *ja, int *ia, int *p, int *aprof, int *verbose){
- /* n: dimension
- nz: number of nonzeros
- ja: array of size nz, holds column indices. 1- based
- ia: array of size n+1, position of row starts. 1-based.
- p: holds the position of row/col i in the permuted matrix. 1-based
- aprof: aprof[0] is the antiband width on entry. aprof[1] is the abtiband on exit
- Verbose: a flag, when set to nonzero, will print the input matrix, as well as others things.
- */
- SparseMatrix A, A2;
- real norm1[3];
- int i, j, jj;
- clock_t start;
- real cpu;
-
- Verbose = *verbose;
- A = SparseMatrix_new(*n, *n, 1, MATRIX_TYPE_PATTERN, FORMAT_COORD);
-
- for (i = 0; i < *n; i++){
- for (j = ia[i] - 1; j < ia[i+1] - 1; j++){
- jj = ja[j] - 1;
- A = SparseMatrix_coordinate_form_add_entries(A, 1, &i, &jj, NULL);
- }
- }
- A2 = SparseMatrix_from_coordinate_format(A);
- if (Verbose && 0) SparseMatrix_print("A = ",A2);
-
- SparseMatrix_delete(A);
- A = SparseMatrix_symmetrize(A2, TRUE);
-
- for (i = 0; i < *n; i++) p[i]--;
-
- ia = A->ia; ja = A->ja;
- get_12_norm(*n, ia, ja, p, norm1);
- if (Verbose) fprintf(stderr,"on entry antibandwidth = %f\n", norm1[0]);
- aprof[0] = (int) norm1[0];
-
- start = clock();
- improve_antibandwidth_by_swapping(A, p);
- cpu = (clock() - start)/(CLOCKS_PER_SEC);
- fprintf(stderr,"cpu = %f\n", cpu);
-
- get_12_norm(*n, ia, ja, p, norm1);
- if (Verbose) fprintf(stderr,"on exit antibandwidth = %f\n", norm1[0]);
- aprof[1] = (int) norm1[0];
- SparseMatrix_delete(A);
- SparseMatrix_delete(A2);
- for (i = 0; i < *n; i++) p[i]++;
-}