src/misc/espresso/dominate.c File Reference

#include "mincov_int.h"
Include dependency graph for dominate.c:

Go to the source code of this file.

Functions

int sm_row_dominance (sm_matrix *A)
int sm_col_dominance (sm_matrix *A, int *weight)

Function Documentation

int sm_col_dominance ( sm_matrix A,
int *  weight 
)

Definition at line 55 of file dominate.c.

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     /* Check each column against all other columns */
00069     for(pcol = A->first_col; pcol != 0; pcol = next_col) {
00070         next_col = pcol->next_col;
00071 
00072         /* Check all rows to find the one with fewest elements */
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         /* Only check for containment against columns in this row */
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 }

int sm_row_dominance ( sm_matrix A  ) 

Definition at line 14 of file dominate.c.

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     /* Check each row against all other rows */
00025     for(prow = A->first_row; prow != 0; prow = prow->next_row) {
00026 
00027         /* Among all columns with a 1 in this row, choose smallest */
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         /* Only check for containment against rows in this column */
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 }


Generated on Tue Jan 5 12:19:10 2010 for abc70930 by  doxygen 1.6.1