/* * Copyright 1997, Regents of the University of Minnesota * * mincover.c * * This file implements the minimum cover algorithm * * Started 8/1/97 * George * * $Id: mincover.c 9942 2011-05-17 22:09:52Z karypis $ */ #include "metislib.h" /************************************************************************* * Constants used by mincover algorithm **************************************************************************/ #define INCOL 10 #define INROW 20 #define VC 1 #define SC 2 #define HC 3 #define VR 4 #define SR 5 #define HR 6 /************************************************************************* * This function returns the min-cover of a bipartite graph. * The algorithm used is due to Hopcroft and Karp as modified by Duff etal * adj: the adjacency list of the bipartite graph * asize: the number of vertices in the first part of the bipartite graph * bsize-asize: the number of vertices in the second part * 0..(asize-1) > A vertices * asize..bsize > B vertices * * Returns: * cover : the actual cover (array) * csize : the size of the cover **************************************************************************/ void MinCover(idx_t *xadj, idx_t *adjncy, idx_t asize, idx_t bsize, idx_t *cover, idx_t *csize) { idx_t i, j; idx_t *mate, *queue, *flag, *level, *lst; idx_t fptr, rptr, lstptr; idx_t row, maxlevel, col; mate = ismalloc(bsize, -1, "MinCover: mate"); flag = imalloc(bsize, "MinCover: flag"); level = imalloc(bsize, "MinCover: level"); queue = imalloc(bsize, "MinCover: queue"); lst = imalloc(bsize, "MinCover: lst"); /* Get a cheap matching */ for (i=0; i