61 assert(iscolored !=
NULL);
63 for( i = 0; i < nV; i++ )
72 weight = weights[V[i]];
75 satdeg = gsd[i].satdeg;
76 if( satdeg > maxsatdeg || (satdeg == maxsatdeg && weight > maxweight) )
84 return maxsatdegindex;
102 assert(getnnodes !=
NULL);
103 assert(getweights !=
NULL);
104 assert(tcliquegraph !=
NULL);
107 weights = getweights(tcliquegraph);
113 for( i = 0 ; i < nV; i++ )
115 assert(0 <= V[i] && V[i] < getnnodes(tcliquegraph));
116 assert(weights[V[i]] > 0);
117 if( weights[V[i]] > maxweight)
120 maxweight = weights[V[i]];
124 assert(maxweightindex >= 0);
126 return maxweightindex;
145 head.next = pgsd->lcitv;
150 while( (pnc !=
NULL) && (pciv !=
NULL) )
152 if( pnc->itv.inf < pciv->itv.inf )
155 nciv->itv = pnc->itv;
162 else if( pnc->itv.inf <= pciv->itv.sup )
164 if( pnc->itv.sup > pciv->itv.sup )
165 pciv->itv.sup = pnc->itv.sup;
178 nciv->itv = pnc->itv;
190 while( (pciv = apciv->next) !=
NULL )
192 if( apciv->itv.sup < (pciv->itv.inf - 1) )
194 pgsd->satdeg += apciv->itv.sup - apciv->itv.inf + 1;
201 if( apciv->itv.sup < pciv->itv.sup )
202 apciv->itv.sup = pciv->itv.sup;
203 apciv->next = pciv->next;
212 pgsd->satdeg += apciv->itv.sup - apciv->itv.inf + 1;
215 pgsd->lcitv = head.next;
255 int weightcurrentclique;
260 assert(getnnodes !=
NULL);
261 assert(getweights !=
NULL);
262 assert(selectadjnodes !=
NULL);
263 assert(buffer !=
NULL);
266 assert(clique !=
NULL);
267 assert(nclique !=
NULL);
268 assert(weightclique !=
NULL);
270 assert(iscolored !=
NULL);
272 weights = getweights(tcliquegraph);
273 assert(weights !=
NULL);
282 node = V[nodeVindex];
283 assert(0 <= node && node < getnnodes(tcliquegraph));
284 range = weights[node];
290 iscolored[nodeVindex] =
TRUE;
293 debugMessage(
"---------------coloring-----------------\n");
294 debugMessage(
"1. node choosen: vindex=%d, vertex=%d, satdeg=%d, range=%d)\n",
295 nodeVindex, node, gsd[nodeVindex].satdeg, range);
298 apbound[nodeVindex] = range;
299 assert(apbound[nodeVindex] > 0);
302 maxsatdegree = range;
308 nVadj = selectadjnodes(tcliquegraph, node, V, nV, Vadj);
309 for( i = 0, adjidx = 0; i < nV && adjidx < nVadj; ++i )
311 assert(V[i] <= Vadj[adjidx]);
312 if( V[i] == Vadj[adjidx] )
315 if( i == nodeVindex )
322 debugMessage(
" nodeVindex=%d, node=%d, weight=%d, satdegold=%d -> ",
323 i, V[i], weights[V[i]], gsd[i].satdeg);
326 gsd[i].satdeg = range;
330 colorinterval->next =
NULL;
331 colorinterval->itv.inf = 1;
332 colorinterval->itv.sup = range;
335 gsd[i].lcitv = colorinterval;
340 debugPrintf(
"satdegnew=%d, nbc=[%d,%d]\n", gsd[i].satdeg, gsd[i].lcitv->itv.inf, gsd[i].lcitv->itv.sup);
349 currentclique[0] = node;
351 weightcurrentclique = range;
354 for( i = 0 ; i < nV-1; i++ )
356 assert((workclique == clique) != (currentclique == clique));
360 if( nodeVindex == -1 )
363 node = V[nodeVindex];
364 assert(0 <= node && node < getnnodes(tcliquegraph));
365 range = weights[node];
367 iscolored[nodeVindex] =
TRUE;
369 debugMessage(
"%d. node choosen: vindex=%d, vertex=%d, satdeg=%d, range=%d, growclique=%u, weight=%d)\n",
370 i+2, nodeVindex, node, gsd[nodeVindex].satdeg, range, growclique, weightcurrentclique);
373 apbound[nodeVindex] = gsd[nodeVindex].satdeg + range;
374 assert(apbound[nodeVindex] > 0);
377 if( maxsatdegree < apbound[nodeVindex] )
378 maxsatdegree = apbound[nodeVindex];
381 if( gsd[nodeVindex].satdeg == 0 )
386 debugMessage(
"current node not adjacend to current clique (weight:%d) -> starting new clique\n",
387 weightcurrentclique);
390 if( weightcurrentclique > *weightclique )
395 assert((workclique == clique) != (currentclique == clique));
397 *weightclique = weightcurrentclique;
398 *nclique = ncurrentclique;
399 workclique = currentclique;
401 assert((workclique == clique) != (currentclique == clique));
403 weightcurrentclique = 0;
410 if( gsd[nodeVindex].satdeg == weightcurrentclique )
412 assert(ncurrentclique < nV);
413 currentclique[ncurrentclique] = node;
415 weightcurrentclique += range;
419 debugMessage(
"current clique (size:%d, weight:%d):", ncurrentclique, weightcurrentclique);
420 for( k = 0; k < ncurrentclique; ++k )
428 debugMessage(
"node satdeg: %d, clique weight: %d -> stop growing clique\n",
429 gsd[nodeVindex].satdeg, weightcurrentclique);
436 if( gsd[nodeVindex].lcitv ==
NULL )
440 colorinterval->next =
NULL;
441 colorinterval->itv.inf = 1;
442 colorinterval->itv.sup = range;
445 pnc->next = colorinterval;
454 lcitv = gsd[nodeVindex].lcitv;
457 if( lcitv->itv.inf != 1 )
460 dif = lcitv->itv.inf - 1 ;
465 colorinterval->next =
NULL;
466 colorinterval->itv.inf = 1;
467 colorinterval->itv.sup = dif;
470 pnc->next = colorinterval;
482 colorinterval->next =
NULL;
483 colorinterval->itv.inf = lcitv->itv.sup+1;
484 if( lcitv->next !=
NULL )
488 min = lcitv->next->itv.inf - lcitv->itv.sup - 1;
494 colorinterval->itv.sup = colorinterval->itv.inf + dif - 1;
497 pnc->next = colorinterval;
506 nVadj = selectadjnodes(tcliquegraph, node, V, nV, Vadj);
507 for( j = 0, adjidx = 0; j < nV && adjidx < nVadj; ++j )
509 assert(V[j] <= Vadj[adjidx]);
510 if( V[j] == Vadj[adjidx] )
514 debugMessage(
" nodeVindex=%d, node=%d, weight=%d, satdegold=%d -> ",
515 j, V[j], weights[V[j]], gsd[j].satdeg);
517 debugPrintf(
"satdegnew=%d, nbc=[%d,%d]\n", gsd[j].satdeg, gsd[j].lcitv->itv.inf, gsd[j].lcitv->itv.sup);
527 while( item !=
NULL )
529 tmpitem = item->next;
536 item = gsd[nodeVindex].lcitv;
537 while( item !=
NULL )
539 tmpitem = item->next;
545 assert((workclique == clique) != (currentclique == clique));
548 if( weightcurrentclique > *weightclique )
553 *weightclique = weightcurrentclique;
554 *nclique = ncurrentclique;
555 workclique = currentclique;
558 assert((workclique == clique) != (currentclique == clique));
561 if( workclique != clique )
563 assert(clique == currentclique);
564 assert(*nclique <= nV);
566 currentclique = workclique;
575 debugMessage(
"------------coloringend-----------------\n");
#define TCLIQUE_GETWEIGHTS(x)
struct BMS_ChkMem BMS_CHKMEM
struct TCLIQUE_Graph TCLIQUE_GRAPH
#define BMSclearChunkMemory(mem)
#define TCLIQUE_SELECTADJNODES(x)
TCLIQUE_WEIGHT tcliqueColoring(TCLIQUE_GETNNODES((*getnnodes)), TCLIQUE_GETWEIGHTS((*getweights)), TCLIQUE_SELECTADJNODES((*selectadjnodes)), TCLIQUE_GRAPH *tcliquegraph, BMS_CHKMEM *mem, int *buffer, int *V, int nV, NBC *gsd, TCLIQUE_Bool *iscolored, TCLIQUE_WEIGHT *apbound, int *clique, int *nclique, TCLIQUE_WEIGHT *weightclique)
#define BMSallocMemoryArray(ptr, num)
coloring part of algorithm for maximum cliques
#define BMSfreeMemoryArray(ptr)
static int getMaxWeightIndex(TCLIQUE_GETNNODES((*getnnodes)), TCLIQUE_GETWEIGHTS((*getweights)), TCLIQUE_GRAPH *tcliquegraph, int *V, int nV)
static int getMaxSatdegIndex(int *V, int nV, NBC *gsd, TCLIQUE_Bool *iscolored, const TCLIQUE_WEIGHT *weights)
#define BMScopyMemoryArray(ptr, source, num)
static void updateNeighbor(BMS_CHKMEM *mem, NBC *pgsd, LIST_ITV *pnc)
#define TCLIQUE_GETNNODES(x)
#define BMSallocChunkMemory(mem, ptr)
#define BMSclearMemoryArray(ptr, num)
#define BMSfreeChunkMemory(mem, ptr)
struct _LIST_ITV LIST_ITV
memory allocation routines