/* --------------------------------------------------------------------- eliminate all nodes in a stage created -- 96feb25, cca --------------------------------------------------------------------- */ void MSMD_eliminateStage ( MSMD *msmd, MSMDinfo *info ) { int ierr, ii, jj, iv, nelim, nreach, stage, step ; int *reach ; IV *reachIV ; MSMDvtx *v ; /* --------------- check the input --------------- */ if ( msmd == NULL || info == NULL ) { fprintf(stderr, "\n fatal error in MSMD_eliminateStage(%p,%p)" "\n bad input\n", msmd, info) ; exit(-1) ; } stage = info->istage ; /* ----------------------------------------------- load the reach set with all nodes in this stage ----------------------------------------------- */ reachIV = &msmd->reachIV ; IV_setSize(reachIV, 0) ; for ( iv = 0, v = msmd->vertices ; iv < msmd->nvtx ; iv++, v++ ) { if ( v->status != 'I' ) { if ( v->stage == stage ) { IV_push(reachIV, v->id) ; v->status = 'R' ; } else if ( v->stage > stage || v->stage < 0 ) { v->status = 'B' ; } } } if ( info->msglvl > 3 ) { fprintf(info->msgFile, "\n after loading reach set") ; IV_fp80(reachIV, info->msgFile, 80, &ierr) ; fflush(info->msgFile) ; } if ( info->seed > 0 ) { IV_shuffle(reachIV, info->seed) ; } if ( info->msglvl > 3 ) { fprintf(info->msgFile, "\n reach set at stage %d", stage) ; IV_fp80(reachIV, info->msgFile, 80, &ierr) ; fflush(info->msgFile) ; } /* ------------------------------------ do an initial update of the vertices ------------------------------------ */ MSMD_update(msmd, info) ; if ( info->msglvl > 4 ) { fprintf(info->msgFile, "\n\n after initial update") ; fflush(info->msgFile) ; } IV_setSize(reachIV, 0) ; /* ----------- elimination ----------- */ step = 0 ; while ( 1 ) { if ( info->msglvl > 1 ) { fprintf(info->msgFile, "\n\n ##### stage %d, elimination step %d", stage, step) ; fflush(info->msgFile) ; } nelim = MSMD_eliminateStep(msmd, info) ; if ( nelim == 0 ) { break ; } /* ----------------------------------------- for each node in the reach set, clean its subtree list and list of uncovered edges ----------------------------------------- */ if ( info->msglvl > 3 ) { fprintf(info->msgFile, "\n calling MSMD_cleanReachSet()") ; fprintf(info->msgFile, "\n reach set") ; IV_fp80(reachIV, info->msgFile, 80, &ierr) ; fflush(info->msgFile) ; } MSMD_cleanReachSet(msmd, info) ; if ( info->msglvl > 3 ) { fprintf(info->msgFile, "\n return from MSMD_cleanReachSet()") ; fflush(info->msgFile) ; } /* ------------------ compress the graph ------------------ */ MSMD_findInodes(msmd, info) ; /* ---------------------------------------------- clean the reach set of indistinguishable nodes and any nodes not on the present stage ---------------------------------------------- */ nreach = IV_size(reachIV) ; reach = IV_entries(reachIV) ; for ( ii = jj = 0 ; ii < nreach ; ii++ ) { if ( reach[ii] < 0 || reach[ii] >= msmd->nvtx ) { fprintf(stderr, "\n fatal error in MSMD_eliminateStage()" "\n reach[%d] = %d", ii, reach[ii]) ; exit(-1) ; } v = msmd->vertices + reach[ii] ; if ( v->status == 'I' ) { continue ; } else if ( v->stage != stage ) { v->status = 'B' ; } else { reach[jj++] = v->id ; } } IV_setSize(reachIV, jj) ; if ( info->msglvl > 2 ) { fprintf(info->msgFile, "\n\n after cleaning reach set, nreach = %d", IV_size(reachIV)) ; fprintf(info->msgFile, "\n reach :") ; IV_fp80(reachIV, info->msgFile, 8, &ierr) ; fflush(info->msgFile) ; } /* ---------------------------------- update the nodes on the reach set ---------------------------------- */ MSMD_update(msmd, info) ; if ( info->msglvl > 2 ) { fprintf(info->msgFile, "\n\n return from update") ; fflush(info->msgFile) ; } IV_setSize(reachIV, 0) ; /* ------------------------------ increment the elimination step ------------------------------ */ step++ ; } if ( info->msglvl > 2 ) { fprintf(info->msgFile, "\n stage %d over, %d steps", stage, step) ; fflush(info->msgFile) ; } /* -------------------------------------- set the number of steps for this stage -------------------------------------- */ info->stageInfo->nstep = step ; return ; }
/* -------------------------------------------- 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 ; }