void _K33Search_ReinitializeGraph(graphP theGraph) { K33SearchContext *context = NULL; gp_FindExtension(theGraph, K33SEARCH_ID, (void *)&context); if (context != NULL) { // Reinitialize the graph context->functions.fpReinitializeGraph(theGraph); // Do the reinitialization that is specific to this module _K33Search_InitStructures(context); LCReset(context->separatedDFSChildLists); LCReset(context->bin); } }
void _K33Search_ReinitializeGraph(graphP theGraph) { K33SearchContext *context = NULL; gp_FindExtension(theGraph, K33SEARCH_ID, (void *)&context); if (context != NULL) { // Reinitialization can go much faster if the underlying // init graph node and vertex rec functions are called, // rather than the overloads of this module, because it // avoids lots of unnecessary gp_FindExtension() calls. if (theGraph->functions.fpInitGraphNode == _K33Search_InitGraphNode && theGraph->functions.fpInitVertexRec == _K33Search_InitVertexRec) { // Restore the graph function pointers theGraph->functions.fpInitGraphNode = context->functions.fpInitGraphNode; theGraph->functions.fpInitVertexRec = context->functions.fpInitVertexRec; // Reinitialize the graph context->functions.fpReinitializeGraph(theGraph); // Restore the function pointers that attach this feature theGraph->functions.fpInitGraphNode = _K33Search_InitGraphNode; theGraph->functions.fpInitVertexRec = _K33Search_InitVertexRec; // Do the reinitialization that is specific to this module _K33Search_InitStructures(context); LCReset(context->sortedDFSChildLists); } // If optimization is not possible, then just stick with what works. // Reinitialize the graph-level structure and then invoke the // reinitialize function. else { LCReset(context->sortedDFSChildLists); // The underlying function fpReinitializeGraph() implicitly initializes the K33 // structures due to the overloads of fpInitGraphNode() and fpInitVertexRec(). // It just does so less efficiently because each invocation of InitGraphNode // and InitVertexRec has to look up the extension again. //// _K33Search_InitStructures(context); context->functions.fpReinitializeGraph(theGraph); } } }
void _ColorVertices_Reinitialize(ColorVerticesContext *context) { int I, N; LCReset(context->degLists); N = context->theGraph->N; for (I=0; I<N; I++) { context->degListHeads[I] = NIL; context->degree[I] = 0; context->color[I] = 0; } context->numVerticesToReduce = 0; context->highestColorUsed = -1; context->colorDetector = NULL; }
void _CreateSeparatedDFSChildLists(graphP theGraph, K33SearchContext *context) { int *buckets; listCollectionP bin; int v, L, DFSParent, theList; buckets = context->buckets; bin = context->bin; // Initialize the bin and all the buckets to be empty LCReset(bin); for (L = gp_GetFirstVertex(theGraph); gp_VertexInRange(theGraph, L); L++) buckets[L] = NIL; // For each vertex, add it to the bucket whose index is equal to the lowpoint of the vertex. for (v = gp_GetFirstVertex(theGraph); gp_VertexInRange(theGraph, v); v++) { L = gp_GetVertexLowpoint(theGraph, v); buckets[L] = LCAppend(bin, buckets[L], v); } // For each bucket, add each vertex in the bucket to the separatedDFSChildList of its DFSParent. // Since lower numbered buckets are processed before higher numbered buckets, vertices with lower // lowpoint values are added before those with higher lowpoint values, so the separatedDFSChildList // of each vertex is sorted by lowpoint for (L = gp_GetFirstVertex(theGraph); gp_VertexInRange(theGraph, L); L++) { v = buckets[L]; // Loop through all the vertices with lowpoint L, putting each in the list of its parent while (gp_IsVertex(v)) { DFSParent = gp_GetVertexParent(theGraph, v); if (gp_IsVertex(DFSParent) && DFSParent != v) { theList = context->VI[DFSParent].separatedDFSChildList; theList = LCAppend(context->separatedDFSChildLists, theList, v); context->VI[DFSParent].separatedDFSChildList = theList; } v = LCGetNext(bin, buckets[L], v); } } }
listCollectionP LCNew(int N) { listCollectionP theListColl = NULL; if (N <= 0) return theListColl; theListColl = (listCollectionP) malloc(sizeof(listCollectionRec)); if (theListColl != NULL) { theListColl->List = (lcnode *) malloc(N*sizeof(lcnode)); if (theListColl->List == NULL) { free(theListColl); theListColl = NULL; } else { theListColl->N = N; LCReset(theListColl); } } return theListColl; }