/* -------------------------------- purpose -- free the Graph object created -- 95sep27, cca -------------------------------- */ void Graph_free ( Graph *g ) { #if MYTRACE > 0 fprintf(stdout, "\n just inside Graph_free(%p)", g) ; fflush(stdout) ; #endif if ( g == NULL ) { fprintf(stderr, "\n fatal error in Graph_free(%p)" "\n graph is NULL\n", g) ; spoolesFatal(); } Graph_clearData(g) ; FREE(g) ; #if MYTRACE > 0 fprintf(stdout, "\n leaving Graph_free(%p)", g) ; fflush(stdout) ; #endif return ; }
/* ------------------------------------------------------- purpose -- to read in a Graph object from a CHACO file input -- fn -- filename return value -- 1 if success, 0 if failure created -- 98sep20, jjs -------------------------------------------------------- */ int Graph_readFromChacoFile ( Graph *graph, char *fn ) { char *rc ; FILE *fp; int nvtx, nedges, format; char string[BUFLEN], *s1, *s2; int k, v, vsize, w, vwghts, ewghts; int *adjncy, *weights, *vwghtsINT; IVL *adjIVL, *ewghtIVL; /* --------------- check the input --------------- */ if ((graph == NULL) || (fn == NULL)) { fprintf(stderr, "\n error in Graph_readFromFile(%p,%s)" "\n bad input\n", graph, fn); return(0); } /* --------------------- clear the data fields --------------------- */ Graph_clearData(graph); /* ---------------------------------------------- open file and read in nvtx, nedges, and format ---------------------------------------------- */ if ((fp = fopen(fn, "r")) == (FILE*)NULL) { fprintf(stderr, "\n error in Graph_readFromChacoFile(%p,%s)" "\n unable to open file %s", graph, fn, fn); return(0); } /* ------------- skip comments ------------- */ do { rc = fgets(string, BUFLEN, fp) ; if ( rc == NULL ) { fprintf(stderr, "\n error in Graph_readFromChacoFile()" "\n error skipping comments in file %s\n", fn) ; return(0) ; } } while ( string[0] == '%'); /* ------------------------------------------------- read in # vertices, # edges and (optional) format ------------------------------------------------- */ format = 0; if (sscanf(string, "%d %d %d", &nvtx, &nedges, &format) < 2) { fprintf(stderr, "\n error in Graph_readFromChacoFile(%p,%s)" "\n unable to read header of file %s", graph, fn, fn); return(0); } ewghts = ((format % 10) > 0); vwghts = (((format / 10) % 10) > 0); if (format >= 100) { fprintf(stderr, "\n error in Graph_readFromChacoFile(%p,%s)" "\n unknown format", graph, fn); return(0); } /* ------------------------------------------------------------------ initialize vector(s) to hold adjacency and (optional) edge weights ------------------------------------------------------------------ */ adjncy = IVinit(nvtx, -1) ; if ( ewghts ) { weights = IVinit(nvtx, -1) ; } else { weights = NULL ; } /* --------------------------- initialize the Graph object --------------------------- */ nedges *= 2; nedges += nvtx; Graph_init1(graph, 2*ewghts+vwghts, nvtx, 0, nedges, IVL_CHUNKED, IVL_CHUNKED); adjIVL = graph->adjIVL; if (ewghts) { ewghtIVL = graph->ewghtIVL; weights[0] = 0; /* self loops have no weight */ } if (vwghts) vwghtsINT = graph->vwghts; /* --------------------------- read in all adjacency lists --------------------------- */ k = 0; for (v = 0; v < nvtx; v++) { /* ------------- skip comments ------------- */ do { rc = fgets(string, BUFLEN, fp); if ( rc == NULL ) { fprintf(stderr, "\n error in Graph_readFromChacoFile()" "\n error reading adjacency for vertex %d in file %s\n", v, fn) ; IVfree(adjncy) ; if ( weights != NULL ) { IVfree(weights) ; } return(0) ; } } while ( string[0] == '%'); /* ------------------------- check for buffer overflow ------------------------- */ if (strlen(string) == BUFLEN-1) { fprintf(stderr, "\n error in Graph_readFromChacoFile(%p,%s)" "\n unable to read adjacency lists of file %s (line " "buffer too small)\n", graph, fn, fn); IVfree(adjncy) ; if ( weights != NULL ) { IVfree(weights) ; } return(0); } /* ---------------------------------------------- read in (optional) vertex weight, adjacent vertices, and (optional) edge weights ---------------------------------------------- */ s1 = string; if (vwghts) vwghtsINT[v] = (int)strtol(string, &s1, 10); adjncy[0] = v; /* insert self loop needed by spooles */ if ( ewghts ) { weights[0] = 0; } vsize = 1; while ((w = (int)strtol(s1, &s2, 10)) > 0) { adjncy[vsize] = --w; /* node numbering starts with 0 */ s1 = s2; if (ewghts) { weights[vsize] = (int)strtol(s1, &s2, 10); s1 = s2; } vsize++; } /* --------------------------------- sort the lists in ascending order --------------------------------- */ if ( ewghts ) { IV2qsortUp(vsize, adjncy, weights) ; } else { IVqsortUp(vsize, adjncy) ; } /* -------------------------------- set the lists in the IVL objects -------------------------------- */ IVL_setList(adjIVL, v, vsize, adjncy); if (ewghts) IVL_setList(ewghtIVL, v, vsize, weights); k += vsize; } /* ----------------------------------- close the file and do a final check ----------------------------------- */ fclose(fp); /* ------------------------ free the working storage ------------------------ */ IVfree(adjncy) ; if ( weights != NULL ) { IVfree(weights) ; } /* ---------------- check for errors ---------------- */ if ((k != nedges) || (v != nvtx)) { fprintf(stderr, "\n error in Graph_readFromChacoFile()" "\n number of nodes/edges does not match with header of %s" "\n k %d, nedges %d, v %d, nvtx %d\n", fn, k, nedges, v, nvtx); return(0); } return(1); }
/* ---------------------------------------------------- purpose -- to read a Graph object from a binary file return value -- 1 if success, 0 if failure created -- 95sep29, cca ---------------------------------------------------- */ int Graph_readFromBinaryFile ( Graph *graph, FILE *fp ) { int nedges, nvbnd, nvtx, rc, totewght, totvwght, type ; int itemp[6] ; int *vwghts ; IVL *adjIVL, *ewghtIVL ; /* --------------- check the input --------------- */ if ( graph == NULL || fp == NULL ) { fprintf(stderr, "\n fatal error in Graph_readFromBinaryFile(%p,%p)" "\n bad input\n", graph, fp) ; return(0) ; } /* --------------------- clear the data fields --------------------- */ Graph_clearData(graph) ; /* --------------------------------------------- read in the six scalar parameters type, nvtx, nvbnd, nedges, totvwght, totewght --------------------------------------------- */ if ( (rc = fread((void *) itemp, sizeof(int), 6, fp)) != 6 ) { fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n %d items of %d read\n", graph, fp, rc, 6) ; return(0) ; } type = itemp[0] ; nvtx = itemp[1] ; nvbnd = itemp[2] ; nedges = itemp[3] ; totvwght = itemp[4] ; totewght = itemp[5] ; /* -------------------------------------------------- create the adjIVL IVL object, set its type to IVL_CHUNKED, then read in its data -------------------------------------------------- */ adjIVL = IVL_new() ; IVL_setDefaultFields(adjIVL) ; adjIVL->type = IVL_CHUNKED ; rc = IVL_readFromBinaryFile(adjIVL, fp) ; if ( rc != 1 ) { fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n trying to read in adjIVL" "\n return code %d from IVL_readBinaryFile(%p,%p)", graph, fp, rc, adjIVL, fp) ; return(0) ; } if ( type % 2 == 1 ) { int nvtot, wght ; /* -------------------------- vertex weights are present -------------------------- */ nvtot = nvtx + nvbnd ; vwghts = IVinit2(nvtot) ; if ( (rc = fread((void *) vwghts, sizeof(int), nvtot, fp)) != nvtot){ fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n %d items of %d read\n", graph, fp, rc, nvtx+nvbnd) ; return(0) ; } wght = IVsum(nvtot, vwghts) ; if ( wght != totvwght ) { fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n totvwght = %d, IVsum(vwghts) = %d\n", graph, fp, totvwght, wght) ; return(0) ; } } else { vwghts = NULL ; } if ( type > 2 ) { int wght ; /* ----------------------------------------------------- edge weights are present, create the ewghtIVL object, set its type to IVL_CHUNKED, then read in its data ----------------------------------------------------- */ ewghtIVL = IVL_new() ; IVL_setDefaultFields(ewghtIVL) ; ewghtIVL->type = IVL_CHUNKED ; rc = IVL_readFromBinaryFile(ewghtIVL, fp) ; if ( rc != 1 ) { fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n trying to read in ewghtIVL" "\n return code %d from IVL_readBinaryFile(%p,%p)", graph, fp, rc, ewghtIVL, fp) ; return(0) ; } wght = IVL_sum(ewghtIVL) ; if ( wght != totewght ) { fprintf(stderr, "\n error in Graph_readFromBinaryFile(%p,%p)" "\n totewght = %d, IVL_sum(ewghtIVL) = %d\n", graph, fp, totewght, wght) ; return(0) ; } } else { ewghtIVL = NULL ; } /* --------------------- initialize the object --------------------- */ Graph_init2(graph, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL) ; return(1) ; }
/* ---------------------------------------------------------------- purpose -- if the elimination has halted before all the stages have been eliminated, then create the schur complement graph and the map from the original vertices those in the schur complement graph. schurGraph -- Graph object to contain the schur complement graph VtoPhi -- IV object to contain the map from vertices in V to schur complement vertices in Phi created -- 97feb01, cca ---------------------------------------------------------------- */ void MSMD_makeSchurComplement ( MSMD *msmd, Graph *schurGraph, IV *VtoPhiIV ) { int nedge, nPhi, nvtx, totewght, totvwght ; int *mark, *rep, *VtoPhi, *vwghts ; int count, *list ; int ierr, ii, size, *adj ; int phi, psi, tag ; IP *ip ; IVL *adjIVL ; MSMDvtx *u, *v, *vertices, *vfirst, *vlast, *w ; /* --------------- check the input --------------- */ if ( msmd == NULL || schurGraph == NULL || VtoPhiIV == NULL ) { fprintf(stderr, "\n\n fatal error in MSMD_makeSchurComplement(%p,%p,%p)" "\n bad input\n", msmd, schurGraph, VtoPhiIV) ; exit(-1) ; } vertices = msmd->vertices ; nvtx = msmd->nvtx ; /* ------------------------------------- initialize the V-to-Phi map IV object ------------------------------------- */ IV_clearData(VtoPhiIV) ; IV_setSize(VtoPhiIV, nvtx) ; IV_fill(VtoPhiIV, -2) ; VtoPhi = IV_entries(VtoPhiIV) ; /* --------------------------------------------- count the number of Schur complement vertices --------------------------------------------- */ vfirst = vertices ; vlast = vfirst + nvtx - 1 ; nPhi = 0 ; for ( v = vfirst ; v <= vlast ; v++ ) { #if MYDEBUG > 0 fprintf(stdout, "\n v->id = %d, v->status = %c", v->id, v->status) ; fflush(stdout) ; #endif switch ( v->status ) { case 'L' : case 'E' : case 'I' : break ; case 'B' : VtoPhi[v->id] = nPhi++ ; #if MYDEBUG > 0 fprintf(stdout, ", VtoPhi[%d] = %d", v->id, VtoPhi[v->id]) ; fflush(stdout) ; #endif break ; default : break ; } } #if MYDEBUG > 0 fprintf(stdout, "\n\n nPhi = %d", nPhi) ; fflush(stdout) ; #endif /* ---------------------------------------------------- get the representative vertex id for each Phi vertex ---------------------------------------------------- */ rep = IVinit(nPhi, -1) ; for ( v = vfirst ; v <= vlast ; v++ ) { if ( (phi = VtoPhi[v->id]) >= 0 ) { #if MYDEBUG > 0 fprintf(stdout, "\n rep[%d] = %d", phi, v->id) ; fflush(stdout) ; #endif rep[phi] = v->id ; } } /* ------------------------------------------ set the map for indistinguishable vertices ------------------------------------------ */ for ( v = vfirst ; v <= vlast ; v++ ) { if ( v->status == 'I' ) { w = v ; while ( w->status == 'I' ) { w = w->par ; } #if MYDEBUG > 0 fprintf(stdout, "\n v = %d, status = %c, w = %d, status = %c", v->id, v->status, w->id, w->status) ; fflush(stdout) ; #endif VtoPhi[v->id] = VtoPhi[w->id] ; } } #if MYDEBUG > 0 fprintf(stdout, "\n\n VtoPhi") ; IV_writeForHumanEye(VtoPhiIV, stdout) ; fflush(stdout) ; #endif /* --------------------------- initialize the Graph object --------------------------- */ Graph_clearData(schurGraph) ; Graph_init1(schurGraph, 1, nPhi, 0, 0, IVL_CHUNKED, IVL_CHUNKED) ; adjIVL = schurGraph->adjIVL ; vwghts = schurGraph->vwghts ; #if MYDEBUG > 0 fprintf(stdout, "\n\n schurGraph initialized, nvtx = %d", schurGraph->nvtx) ; fflush(stdout) ; #endif /* ------------------------------- fill the vertex adjacency lists ------------------------------- */ mark = IVinit(nPhi, -1) ; list = IVinit(nPhi, -1) ; nedge = totvwght = totewght = 0 ; for ( phi = 0 ; phi < nPhi ; phi++ ) { /* ----------------------------- get the representative vertex ----------------------------- */ v = vfirst + rep[phi] ; #if MYDEBUG > 0 fprintf(stdout, "\n phi = %d, v = %d", phi, v->id) ; fflush(stdout) ; MSMDvtx_print(v, stdout) ; fflush(stdout) ; #endif count = 0 ; tag = v->id ; /* --------------------------- load self in adjacency list --------------------------- */ mark[phi] = tag ; totewght += v->wght * v->wght ; #if MYDEBUG > 0 fprintf(stdout, "\n mark[%d] = %d", phi, mark[phi]) ; fflush(stdout) ; #endif list[count++] = phi ; /* ---------------------------------------- load boundary lists of adjacent subtrees ---------------------------------------- */ for ( ip = v->subtrees ; ip != NULL ; ip = ip->next ) { u = vertices + ip->val ; size = u->nadj ; adj = u->adj ; #if MYDEBUG > 0 fprintf(stdout, "\n subtree %d :", u->id) ; IVfp80(stdout, size, adj, 15, &ierr) ; fflush(stdout) ; #endif for ( ii = 0 ; ii < size ; ii++ ) { w = vertices + adj[ii] ; #if MYDEBUG > 0 fprintf(stdout, "\n w %d, status %c, psi %d", w->id, w->status, VtoPhi[w->id]) ; fflush(stdout) ; #endif if ( (psi = VtoPhi[w->id]) != -2 && mark[psi] != tag ) { mark[psi] = tag ; #if MYDEBUG > 0 fprintf(stdout, ", mark[%d] = %d", psi, mark[psi]) ; fflush(stdout) ; #endif list[count++] = psi ; totewght += v->wght * w->wght ; } } } /* ---------------------- load adjacent vertices ---------------------- */ size = v->nadj ; adj = v->adj ; for ( ii = 0 ; ii < size ; ii++ ) { w = vertices + adj[ii] ; if ( (psi = VtoPhi[w->id]) != -2 && mark[psi] != tag ) { mark[psi] = tag ; list[count++] = psi ; totewght += v->wght * w->wght ; } } /* --------------------------------------------- sort the list and inform adjacency IVL object --------------------------------------------- */ IVqsortUp(count, list) ; IVL_setList(adjIVL, phi, count, list) ; /* -------------------------------------- set the vertex weight and increment the total vertex weight and edge count -------------------------------------- */ vwghts[phi] = v->wght ; totvwght += v->wght ; nedge += count ; } schurGraph->totvwght = totvwght ; schurGraph->nedges = nedge ; schurGraph->totewght = totewght ; /* ------------------------ free the working storage ------------------------ */ IVfree(list) ; IVfree(mark) ; IVfree(rep) ; return ; }
/* --------------------------------------------- basic initializer for the Graph object type -- graph type nvtx -- # of vertices nvbnd -- # of boundary vertices nedges -- # of edges adjType -- IVL type for adjacency object ewghtType -- IVL type for edge weights object created -- 95sep27, cca --------------------------------------------- */ void Graph_init1 ( Graph *g, int type, int nvtx, int nvbnd, int nedges, int adjType, int ewghtType ) { int nvtot ; #if MYTRACE > 0 fprintf(stdout, "\n just inside Graph_init1(%p,%d,%d,%d,%d,%d,%d)", g, type, nvtx, nvbnd, nedges, adjType, ewghtType) ; fflush(stdout) ; #endif /* --------------- check the input --------------- */ if ( g == NULL ) { fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n graph is NULL\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType) ; exit(-1) ; } if ( type < 0 || type >= 4 ) { fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n invalid type = %d, must be in [0,3]\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, type) ; exit(-1) ; } if ( nvtx <= 0 ) { fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n nvtx = %d, must be positive\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, nvtx) ; exit(-1) ; } if ( nvbnd < 0 ) { fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n nvbnd = %d, must be nonnegative\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, nvbnd) ; exit(-1) ; } if ( nedges < 0 ) { fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n nedges = %d, must be nonnegative\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, nedges) ; exit(-1) ; } #if MYTRACE > 0 fprintf(stdout, "\n input checks out") ; fflush(stdout) ; #endif switch ( adjType ) { case IVL_CHUNKED : case IVL_SOLO : case IVL_UNKNOWN : break ; default : fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n invalid adjType = %d\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, adjType) ; exit(-1) ; } switch ( ewghtType ) { case IVL_CHUNKED : case IVL_SOLO : case IVL_UNKNOWN : break ; default : fprintf(stderr, "\n fatal error in Graph_init1(%p,%d,%d,%d,%d,%d,%d)" "\n invalid ewghtType = %d\n", g, type, nvtx, nvbnd, nedges, adjType, ewghtType, ewghtType) ; exit(-1) ; } /* ------------------------- clear the data structures ------------------------- */ Graph_clearData(g) ; /* --------------------- set the scalar fields --------------------- */ g->type = type ; g->nvtx = nvtx ; g->nvbnd = nvbnd ; g->nedges = nedges ; nvtot = nvtx + nvbnd ; /* ---------------------------- set the adjacency IVL object ---------------------------- */ g->adjIVL = IVL_new() ; if ( nedges == 0 || adjType == IVL_UNKNOWN ) { IVL_init1(g->adjIVL, adjType, nvtot) ; } else { IVL_init2(g->adjIVL, adjType, nvtot, nedges) ; } if ( type % 2 == 1 ) { /* ----------------------------- set the vertex weights vector ----------------------------- */ g->vwghts = IVinit(nvtot, 0) ; } if ( type >= 2 ) { /* ------------------------------- set the edge weights IVL object ------------------------------- */ g->ewghtIVL = IVL_new() ; if ( nedges == 0 || ewghtType == IVL_UNKNOWN ) { IVL_init1(g->ewghtIVL, ewghtType, nvtot) ; } else { IVL_init2(g->ewghtIVL, ewghtType, nvtot, nedges) ; } } #if MYTRACE > 0 fprintf(stdout, "\n leaving Graph_init1(%p,%d,%d,%d,%d,%d,%d)", g, type, nvtx, nvbnd, nedges, adjType, ewghtType) ; fflush(stdout) ; #endif return ; }
/* -------------------------------------------------------- second initializer for the Graph object. this function is used in the I/O routines Graph_readFromFormattedFile(Graph *g, FILE *fp) and Graph_readFromBinaryFile(Graph *g, FILE *fp) where the IVL object(s) and vwghts[] vector are created independently. type -- graph type nvtx -- # of vertices nvbnd -- # of boundary vertices nedges -- # of edges totvwght -- total vertex weight totewght -- total edge weight adjIVL -- IVL object for adjacency structure vwghts -- pointer to integer vector for vertex weights ewghtIVL -- IVL object for edge weights created -- 95sep27, cca -------------------------------------------------------- */ void Graph_init2 ( Graph *g, int type, int nvtx, int nvbnd, int nedges, int totvwght, int totewght, IVL *adjIVL, int *vwghts, IVL *ewghtIVL ) { #if MYTRACE > 0 fprintf(stdout, "\n just inside Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL) ; fflush(stdout) ; #endif /* --------------- check the input --------------- */ if ( g == NULL ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n graph is NULL\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL) ; exit(-1) ; } if ( type < 0 || type >= 4 ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n invalid type = %d, must be in [0,3]\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, type) ; exit(-1) ; } if ( nvtx <= 0 ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n nvtx = %d, must be positive\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, nvtx) ; exit(-1) ; } if ( nvbnd < 0 ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n nvbnd = %d, must be nonnegative\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, nvbnd) ; exit(-1) ; } if ( nedges < 0 ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n nedges = %d, must be nonnegative\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, nedges) ; exit(-1) ; } if ( adjIVL == NULL ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n adjIVL is NULL\n", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL) ; exit(-1) ; } if ( (type % 2 == 1) && (vwghts == NULL) ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n type = %d, vwghts is NULL", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, type) ; exit(-1) ; } if ( (type >= 2) && (ewghtIVL == NULL) ) { fprintf(stdout, "\n fatal error in Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n type = %d, ewghtIVL is NULL", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, type) ; exit(-1) ; } /* ------------------------- clear the data structures ------------------------- */ Graph_clearData(g) ; /* --------------------- set the scalar fields --------------------- */ g->type = type ; g->nvtx = nvtx ; g->nvbnd = nvbnd ; g->nedges = nedges ; g->totvwght = totvwght ; g->totewght = totewght ; /* --------------------------------------------- set the IVL objects and vertex weights vector --------------------------------------------- */ g->adjIVL = adjIVL ; if ( type % 2 == 1 ) { g->vwghts = vwghts ; } if ( type >= 2 ) { g->ewghtIVL = ewghtIVL ; } #if MYTRACE > 0 fprintf(stdout, "\n leaving Graph_init2(%p,%d,%d,%d,%d,%d,%d,%p,%p,%p)" "\n type = %d, ewghtIVL is NULL", g, type, nvtx, nvbnd, nedges, totvwght, totewght, adjIVL, vwghts, ewghtIVL, type) ; fflush(stdout) ; #endif return ; }