//////////////////////////////////////////////////////////////////////////// // Bincluster.c // // Jorge Vittes // // Functions on binary clusters /////////////////////////////////////////////////////////////////////////// #include #include #include #include "FreeList.h" #include "Data.h" #include "BaseCluster.h" #include "BinCluster.h" #include "UnaryCluster.h" #include "FinalCluster.h" #define AddCluster(a,b,c) AddData(&(a->data),&(b->data), &(c->data)) ////////////////////////////////////////////////////////////////// // Constructor for binary clusters ////////////////////////////////////////////////////////////////// bin_cluster::bin_cluster(bin_data dat) { data = dat; parent = NULL; child = NULL; binaryCl[0] = binaryCl[1] = NULL; affected = 0; for(int i=0;iid,(GET_BC(binaryCl[1]))->id); deprintf("%d endpoints are %d %d:\n",id, endp1,endp2); dataContract(getBinData(binaryCl[0]),getBinData(binaryCl[1]),&(sumCl.data),&data); } /////////////////////////////////////////////////////////////// // Reset the cluster by resetting the data and the pointers /////////////////////////////////////////////////////////////// void bin_cluster::reset() { int i; data.reset(); binaryCl[0] = binaryCl[1] = NULL; for(i=0;i id; } /////////////////////////////////////// // return the non-vanishing endpoint /////////////////////////////////////// int bin_cluster::getNonVanishing() { if (endp1==parent->id) return endp2; else return endp1; } //////////////////////////////////////////// // return an array of all child clusters //////////////////////////////////////////// cluster** bin_cluster::getClusters() { int i; cluster** arr = (cluster**)malloc(sizeof(cluster*)*MAX_DEGREE); for(i=0;i<2;i++) { arr[i] = binaryCl[i]; } for(i=0;igetBinaryClusters (); if (parent -> endpoints > 1) if (GET_CL(p[0])==this) return p+1; else return p; else return NULL; } //////////////////////////////////////////////// // return the array of unary clusters //////////////////////////////////////////////// cluster** bin_cluster::getUnaryClusters() { return (cluster**) unaryCl; } /////////////////////////////////////////////// // return the array of binary clusters /////////////////////////////////////////////// cluster** bin_cluster::getBinaryClusters() { return (cluster**) binaryCl; } //////////////////////////////////////////////// // update the weight //////////////////////////////////////////////// void bin_cluster::updateWeight() { updateDataWeight(&data); }