Skip to content
Snippets Groups Projects
Select Git revision
  • 509e02db33faf9d6cc2a19112382e765ed5b9553
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

mincover.c

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    mincover.c 7.04 KiB
    /*
     * 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,v 1.1 2005-09-07 14:36:45 remacle Exp $
     */
    
    #include <metis.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(idxtype *xadj, idxtype *adjncy, int asize, int bsize, idxtype *cover, int *csize)
    {
      int i, j;
      idxtype *mate, *queue, *flag, *level, *lst;
      int fptr, rptr, lstptr;
      int row, maxlevel, col;
    
      mate = idxsmalloc(bsize, -1, "MinCover: mate");
      flag = idxmalloc(bsize, "MinCover: flag");
      level = idxmalloc(bsize, "MinCover: level");
      queue = idxmalloc(bsize, "MinCover: queue");
      lst = idxmalloc(bsize, "MinCover: lst");
    
      /* Get a cheap matching */
      for (i=0; i<asize; i++) {
        for (j=xadj[i]; j<xadj[i+1]; j++) {
          if (mate[adjncy[j]] == -1) {
            mate[i] = adjncy[j];
            mate[adjncy[j]] = i;
            break;
          }
        }
      }
    
      /* Get into the main loop */
      while (1) {
        /* Initialization */
        fptr = rptr = 0;   /* Empty Queue */
        lstptr = 0;        /* Empty List */