File: split.c

package info (click to toggle)
spooles 2.2-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,760 kB
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,970; perl: 74
file content (108 lines) | stat: -rw-r--r-- 3,033 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*  split.c  */

#include "../GPart.h"

#define MYDEBUG 0

/*--------------------------------------------------------------------*/
/*
   --------------------------------------------
   split the graph partition object into pieces

   created -- 95nov29, cca
   --------------------------------------------
*/
void
GPart_split (
   GPart   *gpart
) {
FILE    *msgFile ;
GPart   *gpartchild ;
Graph   *g, *gchild ;
int     domwght, icomp, ierr, msglvl, ncomp, nvtot, nvtx, sepwght ;
int     *compids, *cweights, *map ;
/*
   ---------------
   check the input
   ---------------
*/
if ( gpart == NULL || (g = gpart->g) == NULL ) {
   fprintf(stderr, "\n fatal error in GPart_split(%p)"
           "\n bad input\n", gpart) ;
   exit(-1) ;
}
if ( gpart->fch != NULL ) {
   fprintf(stderr, "\n fatal error in GPart_split(%p)"
           "\n child(ren) exist, already split\n", gpart) ;
   exit(-1) ;
}
msgFile = gpart->msgFile ;
msglvl  = gpart->msglvl  ;
/*
   ------------------------------
   count the number of subgraphs
   and fill the cweights[] vector
   ------------------------------
*/
nvtx = g->nvtx ;
GPart_setCweights(gpart) ;
ncomp    = gpart->ncomp ;
cweights = IV_entries(&gpart->cweightsIV) ;
if ( msglvl > 1 ) {
   fprintf(msgFile, 
           "\n\n inside GPart_split, %d components, cweights : ", 
           ncomp) ;
   IV_fp80(&gpart->cweightsIV, msgFile, 25, &ierr) ;
}
if ( ncomp == 1 ) {
   return ;
}
/*
   -----------------------------------------
   compute the weight of the components and
   count the number of nontrivial components
   -----------------------------------------
*/
sepwght = cweights[0] ;
domwght = 0 ;
for ( icomp = 1 ; icomp <= ncomp ; icomp++ ) {
   domwght += cweights[icomp] ;
}
if ( msglvl > 1 ) {
   fprintf(msgFile, 
           "\n separator weight = %d, weight of components = %d",
           sepwght, domwght) ;
}
/*
   ------------------------------------------------------
   for each component
      create its subgraph with boundary
      create a GPart object to contain the subgraph
         and set as the child of the present GPart object
   end for
   ------------------------------------------------------
*/
compids = IV_entries(&gpart->compidsIV) ;
for ( icomp = 1 ; icomp <= ncomp ; icomp++ ) {
   gpartchild = GPart_new() ;
   gchild = Graph_subGraph(g, icomp, compids, &map) ;
   if ( msglvl > 3 ) {
      fprintf(msgFile, "\n\n component %d", icomp) ;
      fprintf(msgFile, "\n map to parent") ;
      IVfp80(msgFile, gchild->nvtx + gchild->nvbnd, map, 80, &ierr) ;
      Graph_writeForHumanEye(gchild, msgFile) ;
      fflush(msgFile) ;
   }
   GPart_init(gpartchild, gchild) ;
   nvtot = gpartchild->nvtx + gpartchild->nvbnd ;
   IV_init2(&gpartchild->vtxMapIV, nvtot, nvtot, 1, map) ;
   gpartchild->par = gpart      ;
   gpartchild->sib = gpart->fch ;
   gpart->fch      = gpartchild ;
   gpartchild->msglvl  = gpart->msglvl  ;
   gpartchild->msgFile = gpart->msgFile ;
}

return ; }

/*--------------------------------------------------------------------*/