46 idx_t fptr, rptr, lstptr;
49 mate =
ismalloc(bsize, -1,
"MinCover: mate");
50 flag =
imalloc(bsize,
"MinCover: flag");
51 level =
imalloc(bsize,
"MinCover: level");
52 queue =
imalloc(bsize,
"MinCover: queue");
53 lst =
imalloc(bsize,
"MinCover: lst");
56 for (i=0; i<asize; i++) {
57 for (j=xadj[i]; j<xadj[i+1]; j++) {
58 if (mate[adjncy[j]] == -1) {
71 for (i=0; i<bsize; i++) {
78 for (i=0; i<asize; i++)
85 while (fptr != rptr) {
87 if (level[row] < maxlevel) {
89 for (j=xadj[row]; j<xadj[row+1]; j++) {
93 if (mate[col] == -1) {
94 maxlevel = level[
row];
99 printf(
"\nSomething wrong, flag[%"PRIDX"] is 1",mate[col]);
100 queue[rptr++] = mate[
col];
101 level[mate[
col]] = level[
row] + 1;
112 for (i=0; i<lstptr; i++)
118 gk_free((
void **)&mate, &flag, &level, &queue, &lst,
LTERM);
133 for (i=xadj[col]; i<xadj[col+1]; i++) {
136 if (flag[row] == 1) {
137 if (level[row] == maxlevel) {
140 status =
MinCover_Augment(xadj, adjncy, mate[row], mate, flag, level, maxlevel-1);
169 where =
imalloc(bsize,
"MinCover_Decompose: where");
173 for (i=0; i<asize; i++)
178 for (i=0; i<asize; i++)
185 for (i=0; i<bsize; i++)
191 for (i=0; i<bsize; i++)
192 if (where[i] ==
VC || where[i] ==
SC || where[i] == HR)
197 for (i=0; i<bsize; i++)
198 if (where[i] ==
VC || where[i] ==
SR || where[i] == HR)
217 if (where[root] ==
HC)
220 for (i=xadj[root]; i<xadj[root+1]; i++)
224 if (where[root] ==
HR)
227 if (mate[root] != -1)
242 if (where[root] ==
VR)
245 for (i=xadj[root]; i<xadj[root+1]; i++)
249 if (where[root] ==
VC)
252 if (mate[root] != -1)
void MinCover_Decompose(idx_t *xadj, idx_t *adjncy, idx_t asize, idx_t bsize, idx_t *mate, idx_t *cover, idx_t *csize)
idx_t MinCover_Augment(idx_t *xadj, idx_t *adjncy, idx_t col, idx_t *mate, idx_t *flag, idx_t *level, idx_t maxlevel)
void MinCover_RowDFS(idx_t *xadj, idx_t *adjncy, idx_t root, idx_t *mate, idx_t *where, idx_t flag)
void MinCover_ColDFS(idx_t *xadj, idx_t *adjncy, idx_t root, idx_t *mate, idx_t *where, idx_t flag)
void gk_free(void **ptr1,...)
idx_t idx_t idx_t idx_t * where
idx_t idx_t idx_t * adjncy
void MinCover(idx_t *xadj, idx_t *adjncy, idx_t asize, idx_t bsize, idx_t *cover, idx_t *csize)