00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "mincov_int.h"
00011
00012
00013 int
00014 sm_row_dominance(A)
00015 sm_matrix *A;
00016 {
00017 register sm_row *prow, *prow1;
00018 register sm_col *pcol, *least_col;
00019 register sm_element *p, *pnext;
00020 int rowcnt;
00021
00022 rowcnt = A->nrows;
00023
00024
00025 for(prow = A->first_row; prow != 0; prow = prow->next_row) {
00026
00027
00028 least_col = sm_get_col(A, prow->first_col->col_num);
00029 for(p = prow->first_col->next_col; p != 0; p = p->next_col) {
00030 pcol = sm_get_col(A, p->col_num);
00031 if (pcol->length < least_col->length) {
00032 least_col = pcol;
00033 }
00034 }
00035
00036
00037 for(p = least_col->first_row; p != 0; p = pnext) {
00038 pnext = p->next_row;
00039
00040 prow1 = sm_get_row(A, p->row_num);
00041 if ((prow1->length > prow->length) ||
00042 (prow1->length == prow->length &&
00043 prow1->row_num > prow->row_num)) {
00044 if (sm_row_contains(prow, prow1)) {
00045 sm_delrow(A, prow1->row_num);
00046 }
00047 }
00048 }
00049 }
00050
00051 return rowcnt - A->nrows;
00052 }
00053
00054 int
00055 sm_col_dominance(A, weight)
00056 sm_matrix *A;
00057 int *weight;
00058 {
00059 register sm_row *prow;
00060 register sm_col *pcol, *pcol1;
00061 register sm_element *p;
00062 sm_row *least_row;
00063 sm_col *next_col;
00064 int colcnt;
00065
00066 colcnt = A->ncols;
00067
00068
00069 for(pcol = A->first_col; pcol != 0; pcol = next_col) {
00070 next_col = pcol->next_col;
00071
00072
00073 least_row = sm_get_row(A, pcol->first_row->row_num);
00074 for(p = pcol->first_row->next_row; p != 0; p = p->next_row) {
00075 prow = sm_get_row(A, p->row_num);
00076 if (prow->length < least_row->length) {
00077 least_row = prow;
00078 }
00079 }
00080
00081
00082 for(p = least_row->first_col; p != 0; p = p->next_col) {
00083 pcol1 = sm_get_col(A, p->col_num);
00084 if (weight != 0 && weight[pcol1->col_num] > weight[pcol->col_num])
00085 continue;
00086 if ((pcol1->length > pcol->length) ||
00087 (pcol1->length == pcol->length &&
00088 pcol1->col_num > pcol->col_num)) {
00089 if (sm_col_contains(pcol, pcol1)) {
00090 sm_delcol(A, pcol->col_num);
00091 break;
00092 }
00093 }
00094 }
00095 }
00096
00097 return colcnt - A->ncols;
00098 }