ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
indep.c File Reference
#include "mincov_int.h"
Include dependency graph for indep.c:

Go to the source code of this file.

Functions

solution_tsm_maximal_independent_set (sm_matrix *A, int *weight)
 

Function Documentation

◆ sm_maximal_independent_set()

solution_t * sm_maximal_independent_set ( sm_matrix * A,
int * weight )

Definition at line 44 of file indep.c.

47{
48 register sm_row *best_row, *prow;
49 register sm_element *p;
50 int least_weight;
51 sm_row *save;
52 sm_matrix *B;
53 solution_t *indep;
54
55 indep = solution_alloc();
56 B = build_intersection_matrix(A);
57
58 while (B->nrows > 0) {
59 /* Find the row which is disjoint from a maximum number of rows */
60 best_row = B->first_row;
61 for(prow = B->first_row->next_row; prow != 0; prow = prow->next_row) {
62 if (prow->length < best_row->length) {
63 best_row = prow;
64 }
65 }
66
67 /* Find which element in this row has least weight */
68 if (weight == NIL(int)) {
69 least_weight = 1;
70 } else {
71 prow = sm_get_row(A, best_row->row_num);
72 least_weight = weight[prow->first_col->col_num];
73 for(p = prow->first_col->next_col; p != 0; p = p->next_col) {
74 if (weight[p->col_num] < least_weight) {
75 least_weight = weight[p->col_num];
76 }
77 }
78 }
79 indep->cost += least_weight;
80 (void) sm_row_insert(indep->row, best_row->row_num);
81
82 /* Discard the rows which intersect this row */
83 save = sm_row_dup(best_row);
84 for(p = save->first_col; p != 0; p = p->next_col) {
85 sm_delrow(B, p->col_num);
86 sm_delcol(B, p->col_num);
87 }
88 sm_row_free(save);
89 }
90
91 sm_free(B);
92
93/*
94 if (! verify_indep_set(A, indep->row)) {
95 fail("sm_maximal_independent_set: row set is not independent");
96 }
97*/
98 return indep;
99}
#define NIL(type)
Definition avl.h:25
Cube * p
Definition exorList.c:222
solution_t * solution_alloc()
Definition solution.c:17
struct solution_struct solution_t
Definition mincov_int.h:35
typedefABC_NAMESPACE_HEADER_START struct sm_element_struct sm_element
Definition sparse.h:21
void sm_delcol()
#define sm_get_row(A, rownum)
Definition sparse.h:93
void sm_row_free()
sm_element * sm_row_insert()
void sm_free()
void sm_delrow()
struct sm_matrix_struct sm_matrix
Definition sparse.h:24
struct sm_row_struct sm_row
Definition sparse.h:22
sm_row * sm_row_dup()
sm_row * first_row
Definition sparse.h:79
sm_element * first_col
Definition sparse.h:48
int row_num
Definition sparse.h:45
sm_row * next_row
Definition sparse.h:50
Here is the call graph for this function: