eg_2ptighten.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include "dp_config.h"
00004 #include "eg_mempool.h"
00005 #include "eg_2ptighten.h"
00006 #define KPT_ENABLE 1
00007 #if KPT_ENABLE
00008 #include "eg_ugraph.h"
00009 #include "eg_bit.h"
00010 #include "eg_util.h"
00011 #include "eg_bbtree.h"
00012 #include "eg_2pchecker.h"
00013 /* ========================================================================= */
00014 /* various size, note that the maximujm sizes must be of the form 2^n */
00015 #define KPT_MAX_DOM 512U
00016 #define KPT_MAX_DOM_LOG 9U
00017 #define KPT_MAX_NODE 131072U
00018 #define KPT_MAX_NODE_LOG 17U
00019 #define KPT_MAX_DEPTH 1U
00020 /* ========================================================================= */
00021 /* data structure to handle information about the graph */
00022 /* ========================================================================= */
00023 
00024 /* ========================================================================= */
00026 typedef struct
00027 {
00028   unsigned int n_id:KPT_MAX_NODE_LOG; 
00030   unsigned int move_id:6;             
00031   unsigned int dom;                   
00032 }
00033 KPTMove_t;
00034 
00035 /* ========================================================================= */
00037 typedef struct
00038 {
00039   KPTMove_t move[KPT_MAX_DEPTH];    
00040   double val;                       
00041   unsigned int depth;               
00042 }
00043 KPTFullMove_t;
00044 
00045 /* ========================================================================= */
00047 typedef struct
00048 {
00049   unsigned int n_AH[2];
00050   unsigned int n_BH[2];
00051   unsigned int n_dominos:KPT_MAX_DOM_LOG;
00052   unsigned int n_nodes:KPT_MAX_NODE_LOG;
00053   unsigned int n_A[2][KPT_MAX_DOM];   
00054   unsigned int n_B[2][KPT_MAX_DOM];   
00055   unsigned int n_AdB[2][KPT_MAX_DOM]; 
00056   unsigned int n_Tc[KPT_MAX_DOM];     
00057   EGbitset_t A_partition[EGbitsetSize (KPT_MAX_DOM)];
00060   EGbitset_t B_partition[EGbitsetSize (KPT_MAX_DOM)];
00063   EGbitset_t Kdom[EGbitsetSize (KPT_MAX_DOM)];
00066 }
00067 KPTGdata_t;
00068 
00069 /* ========================================================================= */
00071 typedef union
00072 {
00073   struct
00074   {
00075     unsigned int n_AtoAc:KPT_MAX_DOM_LOG;
00078     unsigned int n_BtoBc:KPT_MAX_DOM_LOG;
00081     unsigned int n_dT:KPT_MAX_DOM_LOG;
00083     unsigned int in_AF:1;     
00084     unsigned int in_BF:1;     
00085   }
00086   num;
00087   unsigned int used;          
00089 }
00090 KPTEdata_t;
00091 
00092 /* ========================================================================= */
00094 struct KPTNdata_t
00095 {
00096   /* ======================================================================= */
00097   /* link to the internal information */
00098   /* ======================================================================= */
00099   EGbbtreeNode_t *tree_cn;      
00101   /* ======================================================================= */
00102   /* cut description, this HAVE to be keeped wright at every iteration */
00103   /* ======================================================================= */
00104   EGbitset_t It[EGbitsetSize (KPT_MAX_DOM)];
00107   EGbitset_t Ia[EGbitsetSize (KPT_MAX_DOM)];
00110   EGbitset_t Ib[EGbitsetSize (KPT_MAX_DOM)];
00113   EGbitset_t Iadb[EGbitsetSize (KPT_MAX_DOM)];
00116   EGbitset_t added[EGbitsetSize (KPT_MAX_DOM)];
00119   EGbitset_t flipAc[EGbitsetSize (KPT_MAX_DOM)];
00122   EGbitset_t flipA[EGbitsetSize (KPT_MAX_DOM)];
00125   EGbitset_t flipBc[EGbitsetSize (KPT_MAX_DOM)];
00128   EGbitset_t flipB[EGbitsetSize (KPT_MAX_DOM)];
00131   unsigned int n_in_B:KPT_MAX_DOM_LOG;
00133   unsigned int n_in_A:KPT_MAX_DOM_LOG;
00135   unsigned int n_in_T:KPT_MAX_DOM_LOG;
00137   unsigned int in_AH:1;         
00138   unsigned int added_AH:1;        
00139   unsigned int in_BH:1;         
00140   unsigned int added_BH:1;        
00141   /* ======================================================================= */
00142   /* move information, this may be changed later on */
00143   /* ======================================================================= */
00144   KPTFullMove_t full_move;      
00145 };
00146 typedef struct KPTNdata_t KPTNdata_t;
00147 
00148 /* ========================================================================= */
00149 /* static variables, these variables hold the graphData, node data and edge
00150  * data, the later two indexed by node->id and edge->id respectivelly. */
00151 static KPTNdata_t *nodeData = 0;
00152 static KPTEdata_t *edgeData = 0;
00153 static KPTGdata_t graphData;
00154 static EGuGraph_t *G = 0;
00155 static EGuGraphNode_t **all_nodes;
00156 static EGuGraphEdge_t **all_edges;
00157 static double const *weight;
00158 static EGbbtree_t *tree;
00159 static EGbitset_t node_update[EGbitsetSize (KPT_MAX_NODE)];
00160 
00161 /* ========================================================================= */
00162 /* some macros to make access easy */
00163 /* ========================================================================= */
00164 /* the minimum improvement is for the local search, if negative it means that it
00165  * will allow movements that may worsen the inequality */
00166 #define KPTMinImprovement (-1e-7)
00167 
00168 /* constants for the moves */
00169 enum move
00170 {                               /* adding moves: */
00171   KPT_Tc_AB,                    /* move from outside the teeth to A and B */
00172   KPT_Tc_AcB,                   /* move from outside the teeth to Ac and B */
00173   KPT_Tc_ABc,                   /* move from outside the teeth to A and Bc */
00174   KPT_Tc_AcBc,                  /* move from outside the teeth to Ac and Bc */
00175   KPT_Tc_A,                     /* move from Tc to A */
00176   KPT_Tc_B,                     /* move from Tc to B */
00177   KPT_Tc_Ac,                    /* move from Tc to Ac */
00178   KPT_Tc_Bc,                    /* move from Tc to Bc */
00179   KPT_AHc_AH,                   /* move a node from AHc to AH */
00180   KPT_BHc_BH,                   /* move a node from BHc to BH */
00181   KPT_AHc_AH_BHc_BH,            /* move a node from xHc to xH */
00182   /* fliping moves */
00183   KPT_Ac_A,                     /* flip within the A set in T */
00184   KPT_Bc_B,                     /* flip within the B set in T */
00185   KPT_A_Ac,                     /* flip within the A set in T */
00186   KPT_B_Bc,                     /* flip within the B set in T */
00187   KPT_A_Ac_B_Bc,                /* flip both A and B within T */
00188   KPT_A_Ac_Bc_B,                /* flip both A and B within T */
00189   KPT_Ac_A_B_Bc,                /* flip both A and B within T */
00190   KPT_Ac_A_Bc_B,                /* flip both A and B within T */
00191   KPT_Ac_A_flipAH,              /* flip A and Ahandle */
00192   KPT_Bc_B_flipBH,              /* flip B and Bhandle */
00193   KPT_A_Ac_flipAH,              /* flip A and Ahandle */
00194   KPT_B_Bc_flipBH,              /* flip B and Bhandle */
00195   KPT_A_Ac_B_Bc_flipAH,         /* flip both A and B within T */
00196   KPT_A_Ac_Bc_B_flipAH,         /* flip both A and B within T */
00197   KPT_Ac_A_B_Bc_flipAH,         /* flip both A and B within T */
00198   KPT_Ac_A_Bc_B_flipAH,         /* flip both A and B within T */
00199   KPT_A_Ac_B_Bc_flipBH,         /* flip both A and B within T */
00200   KPT_A_Ac_Bc_B_flipBH,         /* flip both A and B within T */
00201   KPT_Ac_A_B_Bc_flipBH,         /* flip both A and B within T */
00202   KPT_Ac_A_Bc_B_flipBH,         /* flip both A and B within T */
00203   KPT_A_Ac_B_Bc_flipAHBH,       /* flip both A and B, and AH, BH */
00204   KPT_A_Ac_Bc_B_flipAHBH,       /* flip both A and B within T */
00205   KPT_Ac_A_B_Bc_flipAHBH,       /* flip both A and B within T */
00206   KPT_Ac_A_Bc_B_flipAHBH,       /* flip both A and B within T */
00207   KPT_AH_AHc_BHc_BH,            /* flip both handles */
00208   KPT_AHc_AH_BH_BHc,            /* flip both handles */
00209   /* shrinking moves */
00210   KPT_AcBc_Tc,                  /* move from outside the teeth to Ac and Bc */
00211   KPT_AcB_Tc,                   /* move from outside the teeth to Ac and B */
00212   KPT_ABc_Tc,                   /* move from outside the teeth to A and Bc */
00213   KPT_AB_Tc,                    /* move from outside the teeth to A and B */
00214   KPT_A_Tc,                     /* move from Tc to A */
00215   KPT_B_Tc,                     /* move from Tc to B */
00216   KPT_Ac_Tc,                    /* move from Tc to Ac */
00217   KPT_Bc_Tc,                    /* move from Tc to Bc */
00218   KPT_AH_AHc,                   /* move a node from AHc to AH */
00219   KPT_BH_BHc,                   /* move a node from BHc to BH */
00220   KPT_AH_AHc_BH_BHc,            /* take out the node from both handles */
00221   KPT_no_move                   /* no feasible move found */
00222 };
00223 
00224 /* string names for the moves */
00225 static const char move_name[61][40] = {
00226   [KPT_A_Tc] = "KPT_A_Tc",
00227   [KPT_B_Tc] = "KPT_B_Tc",
00228   [KPT_Ac_Tc] = "KPT_Ac_Tc",
00229   [KPT_Bc_Tc] = "KPT_Bc_Tc",
00230   [KPT_Tc_A] = "KPT_Tc_A",
00231   [KPT_Tc_B] = "KPT_Tc_B",
00232   [KPT_Tc_Ac] = "KPT_Tc_Ac",
00233   [KPT_Tc_Bc] = "KPT_Tc_Bc",
00234   [KPT_Tc_AB] = "KPT_Tc_AB",
00235   [KPT_Tc_AcB] = "KPT_Tc_AcB",
00236   [KPT_Tc_ABc] = "KPT_Tc_ABc",
00237   [KPT_Tc_AcBc] = "KPT_Tc_AcBc",
00238   [KPT_AHc_AH] = "KPT_AHc_AH",
00239   [KPT_BHc_BH] = "KPT_BHc_BH",
00240   [KPT_AHc_AH_BHc_BH] = "KPT_AHc_AH_BHc_BH",
00241   [KPT_Ac_A] = "KPT_Ac_A",
00242   [KPT_Bc_B] = "KPT_Bc_B",
00243   [KPT_A_Ac] = "KPT_A_Ac",
00244   [KPT_B_Bc] = "KPT_B_Bc",
00245   [KPT_Ac_A_Bc_B] = "KPT_Ac_A_Bc_B",
00246   [KPT_A_Ac_Bc_B] = "KPT_A_Ac_Bc_B",
00247   [KPT_Ac_A_B_Bc] = "KPT_Ac_A_B_Bc",
00248   [KPT_A_Ac_B_Bc] = "KPT_A_Ac_B_Bc",
00249   [KPT_Ac_A_Bc_B_flipAH] = "KPT_Ac_A_Bc_B_flipAH",
00250   [KPT_A_Ac_Bc_B_flipAH] = "KPT_A_Ac_Bc_B_flipAH",
00251   [KPT_Ac_A_B_Bc_flipAH] = "KPT_Ac_A_B_Bc_flipAH",
00252   [KPT_A_Ac_B_Bc_flipAH] = "KPT_A_Ac_B_Bc_flipAH",
00253   [KPT_Ac_A_Bc_B_flipBH] = "KPT_Ac_A_Bc_B_flipBH",
00254   [KPT_A_Ac_Bc_B_flipBH] = "KPT_A_Ac_Bc_B_flipBH",
00255   [KPT_Ac_A_B_Bc_flipBH] = "KPT_Ac_A_B_Bc_flipBH",
00256   [KPT_A_Ac_B_Bc_flipBH] = "KPT_A_Ac_B_Bc_flipBH",
00257   [KPT_Ac_A_Bc_B_flipAHBH] = "KPT_Ac_A_Bc_B_flipAHBH",
00258   [KPT_A_Ac_Bc_B_flipAHBH] = "KPT_A_Ac_Bc_B_flipAHBH",
00259   [KPT_Ac_A_B_Bc_flipAHBH] = "KPT_Ac_A_B_Bc_flipAHBH",
00260   [KPT_A_Ac_B_Bc_flipAHBH] = "KPT_A_Ac_B_Bc_flipAHBH",
00261   [KPT_AH_AHc_BHc_BH] = "KPT_AH_AHc_BHc_BH",
00262   [KPT_AHc_AH_BH_BHc] = "KPT_AHc_AH_BH_BHc",
00263   [KPT_Ac_A_flipAH] = "KPT_Ac_A_flipAH",
00264   [KPT_Bc_B_flipBH] = "KPT_Bc_B_flipBH",
00265   [KPT_A_Ac_flipAH] = "KPT_A_Ac_flipAH",
00266   [KPT_B_Bc_flipBH] = "KPT_B_Bc_flipBH",
00267   [KPT_AB_Tc] = "KPT_AB_Tc",
00268   [KPT_AcB_Tc] = "KPT_AcB_Tc",
00269   [KPT_ABc_Tc] = "KPT_ABc_Tc",
00270   [KPT_AcBc_Tc] = "KPT_AcBc_Tc",
00271   [KPT_AHc_AH] = "KPT_AHc_AH",
00272   [KPT_BH_BHc] = "KPT_BH_BHc",
00273   [KPT_AH_AHc_BH_BHc] = "KPT_AH_AHc_BH_BHc",
00274   [KPT_no_move] = "KPT_no_move"
00275 };
00276 /* inverse move for every move */
00277 static unsigned char KPT_inv_move[61] = {
00278   [KPT_A_Tc] = KPT_Tc_A,
00279   [KPT_B_Tc] = KPT_Tc_B,
00280   [KPT_Ac_Tc] = KPT_Tc_Ac,
00281   [KPT_Bc_Tc] = KPT_Tc_Bc,
00282   [KPT_Tc_A] = KPT_A_Tc,
00283   [KPT_Tc_B] = KPT_B_Tc,
00284   [KPT_Tc_Ac] = KPT_Ac_Tc,
00285   [KPT_Tc_Bc] = KPT_Bc_Tc,
00286   [KPT_Tc_AB] = KPT_AB_Tc,
00287   [KPT_Tc_AcB] = KPT_AcB_Tc,
00288   [KPT_Tc_ABc] = KPT_ABc_Tc,
00289   [KPT_Tc_AcBc] = KPT_AcBc_Tc,
00290   [KPT_AHc_AH] = KPT_AH_AHc,
00291   [KPT_BHc_BH] = KPT_BH_BHc,
00292   [KPT_AHc_AH_BHc_BH] = KPT_AH_AHc_BH_BHc,
00293   [KPT_Ac_A] = KPT_A_Ac,
00294   [KPT_Bc_B] = KPT_B_Bc,
00295   [KPT_A_Ac] = KPT_Ac_A,
00296   [KPT_B_Bc] = KPT_Bc_B,
00297   [KPT_Ac_A_Bc_B] = KPT_A_Ac_B_Bc,
00298   [KPT_A_Ac_B_Bc] = KPT_Ac_A_Bc_B,
00299   [KPT_A_Ac_Bc_B] = KPT_Ac_A_B_Bc,
00300   [KPT_Ac_A_B_Bc] = KPT_A_Ac_Bc_B,
00301   [KPT_Ac_A_Bc_B_flipBH] = KPT_A_Ac_B_Bc_flipBH,
00302   [KPT_A_Ac_Bc_B_flipBH] = KPT_Ac_A_B_Bc_flipBH,
00303   [KPT_Ac_A_B_Bc_flipBH] = KPT_A_Ac_Bc_B_flipBH,
00304   [KPT_A_Ac_B_Bc_flipBH] = KPT_Ac_A_Bc_B_flipBH,
00305   [KPT_Ac_A_Bc_B_flipAH] = KPT_A_Ac_B_Bc_flipAH,
00306   [KPT_A_Ac_Bc_B_flipAH] = KPT_Ac_A_B_Bc_flipAH,
00307   [KPT_Ac_A_B_Bc_flipAH] = KPT_A_Ac_Bc_B_flipAH,
00308   [KPT_A_Ac_B_Bc_flipAH] = KPT_Ac_A_Bc_B_flipAH,
00309   [KPT_Ac_A_Bc_B_flipAHBH] = KPT_A_Ac_B_Bc_flipAHBH,
00310   [KPT_A_Ac_Bc_B_flipAHBH] = KPT_Ac_A_B_Bc_flipAHBH,
00311   [KPT_Ac_A_B_Bc_flipAHBH] = KPT_A_Ac_Bc_B_flipAHBH,
00312   [KPT_A_Ac_B_Bc_flipAHBH] = KPT_Ac_A_Bc_B_flipAHBH,
00313   [KPT_AH_AHc_BHc_BH] = KPT_AHc_AH_BH_BHc,
00314   [KPT_AHc_AH_BH_BHc] = KPT_AH_AHc_BHc_BH,
00315   [KPT_Ac_A_flipAH] = KPT_A_Ac_flipAH,
00316   [KPT_Bc_B_flipBH] = KPT_B_Bc_flipBH,
00317   [KPT_A_Ac_flipAH] = KPT_Ac_A_flipAH,
00318   [KPT_B_Bc_flipBH] = KPT_Bc_B_flipBH,
00319   [KPT_AB_Tc] = KPT_Tc_AB,
00320   [KPT_AcB_Tc] = KPT_Tc_AcB,
00321   [KPT_ABc_Tc] = KPT_Tc_ABc,
00322   [KPT_AcBc_Tc] = KPT_Tc_AcBc,
00323   [KPT_AHc_AH] = KPT_AH_AHc,
00324   [KPT_BH_BHc] = KPT_BHc_BH,
00325   [KPT_AH_AHc_BH_BHc] = KPT_AHc_AH_BHc_BH,
00326   [KPT_no_move] = KPT_no_move
00327 };
00328 
00329 /* ========================================================================= */
00330 /* some macros */
00331 #define KPTgetEdge(__e_it) ((EGuGraphEdge_t*)(__e_it->this))
00332 #define KPTgetOtherEndId(__n_id,__e_it) (__n_id == KPTgetEdge(__e_it)->head->id ? KPTgetEdge(__e_it)->tail->id : KPTgetEdge(__e_it)->head->id)
00333 #define KPTgetEdgeId(__e_it) (KPTgetEdge(__e_it)->id)
00334 #define KPTNdata(__this) ((KPTNdata_t*)(__this))
00335 
00336 /* ========================================================================= */
00337 /* local static functions */
00338 /* ========================================================================= */
00339 
00340 #if KPT_DBG < DEBUG || KPT_EDBG < DEBUG || KPT_VRB < DEBUG
00341 /* ========================================================================= */
00342 /* this function display on the screen what move are we performing */
00343 /* ========================================================================= */
00344 static inline void DPdisplaySingleMove (const KPTMove_t * const move)
00345 {
00346   /* local variables */
00347   EGlistNode_t *e_it;
00348   unsigned no_id = move->n_id,
00349     e_id,
00350     dom = move->dom;
00351   /* printing information */
00352   fprintf (stderr, "\tNode %u:%s:%u", no_id, move_name[move->move_id], dom);
00353   switch (move->move_id)
00354   {
00355   case KPT_AB_Tc:
00356   case KPT_AcB_Tc:
00357   case KPT_ABc_Tc:
00358   case KPT_AcBc_Tc:
00359   case KPT_Tc_AB:
00360   case KPT_Tc_AcB:
00361   case KPT_Tc_ABc:
00362   case KPT_Tc_AcBc:
00363   case KPT_Ac_A:
00364   case KPT_A_Ac:
00365   case KPT_Bc_B:
00366   case KPT_B_Bc:
00367   case KPT_Ac_A_B_Bc:
00368   case KPT_Ac_A_Bc_B:
00369   case KPT_A_Ac_B_Bc:
00370   case KPT_A_Ac_Bc_B:
00371   case KPT_Ac_A_B_Bc_flipBH:
00372   case KPT_Ac_A_Bc_B_flipBH:
00373   case KPT_A_Ac_B_Bc_flipBH:
00374   case KPT_A_Ac_Bc_B_flipBH:
00375   case KPT_Ac_A_B_Bc_flipAH:
00376   case KPT_Ac_A_Bc_B_flipAH:
00377   case KPT_A_Ac_B_Bc_flipAH:
00378   case KPT_A_Ac_Bc_B_flipAH:
00379   case KPT_Ac_A_B_Bc_flipAHBH:
00380   case KPT_Ac_A_Bc_B_flipAHBH:
00381   case KPT_A_Ac_B_Bc_flipAHBH:
00382   case KPT_A_Ac_Bc_B_flipAHBH:
00383   case KPT_Ac_A_flipAH:
00384   case KPT_A_Ac_flipAH:
00385   case KPT_Bc_B_flipBH:
00386   case KPT_B_Bc_flipBH:
00387   case KPT_A_Tc:
00388   case KPT_B_Tc:
00389   case KPT_Ac_Tc:
00390   case KPT_Bc_Tc:
00391   case KPT_Tc_A:
00392   case KPT_Tc_B:
00393   case KPT_Tc_Ac:
00394   case KPT_Tc_Bc:
00395     fprintf (stderr, ":%s_%u(%u,%u,%u,%u,%u)%s(%u,%u)%s(%u,%u)%s_%s(%u,%u)",
00396              !EGbitTest (nodeData[no_id].It, dom) ? "Tc" :
00397              EGbitTest (nodeData[no_id].Ia, dom) &&
00398              EGbitTest (nodeData[no_id].Ib, dom) ? "TAB" :
00399              EGbitTest (nodeData[no_id].Ia, dom) ? "TABc" :
00400              EGbitTest (nodeData[no_id].Ib, dom) ? "TAcB" : "TAcBc",
00401              dom, graphData.n_A[1][dom], graphData.n_A[0][dom],
00402              graphData.n_B[1][dom], graphData.n_B[0][dom],
00403              graphData.n_Tc[dom], nodeData[no_id].in_AH ? "aH" : "aHc",
00404              graphData.n_AH[1], graphData.n_AH[0],
00405              nodeData[no_id].in_BH ? "bH" : "bHc",
00406              graphData.n_BH[1], graphData.n_BH[0],
00407              EGbitTest (graphData.Kdom, dom) ? "2dom" : "1dom",
00408              EGbitTest (nodeData[no_id].Iadb, dom) ? "AdB" : "AdBc",
00409              graphData.n_AdB[1][dom], graphData.n_AdB[0][dom]);
00410     /* printing adjacent edges information */
00411     for (e_it = all_nodes[no_id]->edges->begin; e_it; e_it = e_it->next)
00412     {
00413       no_id = KPTgetOtherEndId (move->n_id, e_it);
00414       e_id = KPTgetEdgeId (e_it);
00415       fprintf (stderr, "\n\t\te=(%u,%u:%s)%s:%s[%8.6lf]F[%u,%u]",
00416                move->n_id, no_id,
00417                !EGbitTest (nodeData[no_id].It, dom) ? "Tc" :
00418                EGbitTest (nodeData[no_id].Ia, dom) &&
00419                EGbitTest (nodeData[no_id].Ib, dom) ? "TAB" :
00420                EGbitTest (nodeData[no_id].Ia, dom) ? "TABc" :
00421                EGbitTest (nodeData[no_id].Ib, dom) ? "TAcB" : "TAcBc",
00422                nodeData[no_id].in_AH ? "aH" : "aHc",
00423                nodeData[no_id].in_BH ? "bH" : "bHc",
00424                weight[e_id], edgeData[e_id].num.in_AF,
00425                edgeData[e_id].num.in_BF);
00426     }
00427     break;
00428   case KPT_AHc_AH:
00429   case KPT_BHc_BH:
00430   case KPT_AH_AHc:
00431   case KPT_BH_BHc:
00432   case KPT_AH_AHc_BH_BHc:
00433   case KPT_AH_AHc_BHc_BH:
00434   case KPT_AHc_AH_BHc_BH:
00435   case KPT_AHc_AH_BH_BHc:
00436     fprintf (stderr, ":%s(%u,%u)%s(%u,%u)",
00437              nodeData[no_id].in_AH ? "aH" : "aHc", graphData.n_AH[1],
00438              graphData.n_AH[0], nodeData[no_id].in_BH ? "bH" : "bHc",
00439              graphData.n_BH[1], graphData.n_BH[0]);
00440     /* printing adjacent edges information */
00441     for (e_it = all_nodes[no_id]->edges->begin; e_it; e_it = e_it->next)
00442     {
00443       no_id = KPTgetOtherEndId (move->n_id, e_it);
00444       e_id = KPTgetEdgeId (e_it);
00445       fprintf (stderr, "\n\t\te=(%u,%u)%s:%s[%8.6lf]F[%u,%u]",
00446                move->n_id, no_id, nodeData[no_id].in_AH ? "aH" : "aHc",
00447                nodeData[no_id].in_BH ? "bH" : "bHc",
00448                weight[e_id], edgeData[e_id].num.in_AF,
00449                edgeData[e_id].num.in_BF);
00450     }
00451     break;
00452   }
00453   fprintf (stderr, "\n");
00454 }
00455 
00456 /* ========================================================================= */
00457 /* this function display on the screen what move are we performing */
00458 /* ========================================================================= */
00459 static inline int DPdisplayMove (unsigned int const nc_id)
00460 {
00461   unsigned depth = nodeData[nc_id].full_move.depth;
00462   fprintf (stderr, "Move Stored for node %u:%u\n", nc_id,
00463            nodeData[nc_id].full_move.depth);
00464   while (depth--)
00465     DPdisplaySingleMove (nodeData[nc_id].full_move.move + depth);
00466   fprintf (stderr, "\tValue %lf\n", nodeData[nc_id].full_move.val);
00467   fprintf (stderr, "\t");
00468   __EG_PRINTLOC2__;
00469   return 1;
00470 }
00471 #endif
00472 /* ========================================================================= */
00473 /* this function compute the violation of the curently stored constraint */
00474 /* ========================================================================= */
00475 static inline void KPTpriceConstraint (double *l_violation)
00476 {
00477   register unsigned int i;
00478   /* finally we compute the in_F field for all edges */
00479   for (i = G->nedges; i--;)
00480   {
00481     (*l_violation) += (edgeData[i].num.in_AF + edgeData[i].num.in_BF +
00482                        edgeData[i].num.n_AtoAc + edgeData[i].num.n_BtoBc +
00483                        edgeData[i].num.n_dT) * weight[i];
00484   }
00485   return;
00486 }
00487 
00488 #if (KPT_VRB <= DEBUG-1) || (KPT_EDBG <= DEBUG)
00489 /* ========================================================================= */
00491 /* ========================================================================= */
00492 static inline int KPTDisplayEdges (void)
00493 {
00494   register unsigned int i;
00495   register unsigned j;
00496   unsigned h_id,
00497     t_id;
00498   /* finally we compute the in_F field for all edges */
00499   for (i = G->nedges; i--;)
00500   {
00501     h_id = all_edges[i]->head->id;
00502     t_id = all_edges[i]->tail->id;
00503     if (weight[i] > 1e-3)
00504     {
00505       fprintf (stderr, "e(%u)[%u,%u][%8.6lf] bellongs to: ", i,
00506                h_id, t_id, weight[i]);
00507       for (j = graphData.n_dominos; j--;)
00508       {
00509         if (EGbitTest (nodeData[h_id].It, j) !=
00510             EGbitTest (nodeData[t_id].It, j))
00511           fprintf (stderr, "delta(T_%u) ", j);
00512         if (EGbitTest (nodeData[h_id].Ia, j) !=
00513             EGbitTest (nodeData[t_id].Ia, j))
00514           fprintf (stderr, "delta(A_%u) ", j);
00515         if (EGbitTest (nodeData[h_id].Ib, j) !=
00516             EGbitTest (nodeData[t_id].Ib, j))
00517           fprintf (stderr, "delta(B_%u) ", j);
00518       }
00519       if (nodeData[h_id].in_AH != nodeData[t_id].in_AH)
00520         fprintf (stderr, "delta(AH) ");
00521       if (nodeData[h_id].in_BH != nodeData[t_id].in_BH)
00522         fprintf (stderr, "delta(BH) ");
00523       if (edgeData[i].num.in_AF)
00524         fprintf (stderr, "AF ");
00525       if (edgeData[i].num.in_BF)
00526         fprintf (stderr, "BF ");
00527       fprintf (stderr, "\n");
00528     }
00529   }
00530   return 1;
00531 }
00532 #endif
00533 
00534 /* ========================================================================= */
00536 /* ========================================================================= */
00537 static int EGdpTightNdataCompare (const void *N1,
00538                                   const void *N2)
00539 {
00540   /* we first check if the values are near-zero, if so, we sort according to 
00541    * the type of the movement */
00542   if ((fabs (((const KPTNdata_t *) N1)->full_move.val) <
00543        fabs (KPTMinImprovement))
00544       && (fabs (((const KPTNdata_t *) N2)->full_move.val) <
00545           fabs (KPTMinImprovement)))
00546   {
00547     /* Sort by first move order */
00548     if (((const KPTNdata_t *) N1)->full_move.move[0].move_id <
00549         ((const KPTNdata_t *) N2)->full_move.move[0].move_id)
00550       return -1;
00551     if (((const KPTNdata_t *) N1)->full_move.move[0].move_id >
00552         ((const KPTNdata_t *) N2)->full_move.move[0].move_id)
00553       return 1;
00554     /* if they have the same type. choose by simplicity */
00555     if (((const KPTNdata_t *) N1)->full_move.depth <
00556         ((const KPTNdata_t *) N2)->full_move.depth)
00557       return -1;
00558     if (((const KPTNdata_t *) N1)->full_move.depth >
00559         ((const KPTNdata_t *) N2)->full_move.depth)
00560       return 1;
00561     if( N1 < N2)
00562       return -1;
00563     if(N1 > N2)
00564       return 1;
00565     return 0;
00566   }
00567   /* otherwise we sort by value */
00568   if (((const KPTNdata_t *) N1)->full_move.val <
00569       ((const KPTNdata_t *) N2)->full_move.val)
00570     return -1;
00571   if (((const KPTNdata_t *) N1)->full_move.val >
00572       ((const KPTNdata_t *) N2)->full_move.val)
00573     return 1;
00574   if( N1 < N2)
00575     return -1;
00576   if(N1 > N2)
00577     return 1;
00578   return 0;
00579 }
00580 
00581 /* ######################################################################### */
00582 /* makeMove functions */
00583 /* ######################################################################### */
00584 
00585 /* ========================================================================= */
00586 /* macro definitions to move around nodes */
00587 /* ========================================================================= */
00588 #define KPTmoveBH(__n_id) {\
00589   graphData.n_BH[nodeData[__n_id].in_BH]--;\
00590   nodeData[__n_id].in_BH++;\
00591   graphData.n_BH[nodeData[__n_id].in_BH]++;}
00592 
00593 #define KPTmoveAH(__n_id) {\
00594   graphData.n_AH[nodeData[__n_id].in_AH]--;\
00595   nodeData[__n_id].in_AH++;\
00596   graphData.n_AH[nodeData[__n_id].in_AH]++;}
00597 
00598 #define KPTmoveAdB(__n_id,__dom) {\
00599   if(EGbitTest(graphData.Kdom,__dom)){\
00600   graphData.n_AdB[EGbitTest(nodeData[__n_id].Iadb,__dom)?1U:0U][__dom]--;\
00601   graphData.n_AdB[EGbitTest(nodeData[__n_id].Iadb,__dom)?0U:1U][__dom]++;\
00602   EGbitTest(nodeData[__n_id].Iadb,__dom) ? \
00603   EGbitUnset(nodeData[__n_id].Iadb,__dom): \
00604   EGbitSet(nodeData[__n_id].Iadb,__dom);}}
00605 
00606 #define KPTmoveAAc(__n_id,__dom) {\
00607   graphData.n_A[1][__dom]--;\
00608   graphData.n_A[0][__dom]++;\
00609   EGbitUnset(nodeData[__n_id].Ia,__dom);\
00610   nodeData[__n_id].n_in_A--;}
00611 
00612 #define KPTmoveBBc(__n_id,__dom) {\
00613   graphData.n_B[1][__dom]--;\
00614   graphData.n_B[0][__dom]++;\
00615   EGbitUnset(nodeData[__n_id].Ib,__dom);\
00616   nodeData[__n_id].n_in_B--;}
00617 
00618 #define KPTmoveAcA(__n_id,__dom) {\
00619   graphData.n_A[0][__dom]--;\
00620   graphData.n_A[1][__dom]++;\
00621   EGbitSet(nodeData[__n_id].Ia,__dom);\
00622   nodeData[__n_id].n_in_A++;}
00623 
00624 #define KPTmoveBcB(__n_id,__dom) {\
00625   graphData.n_B[0][__dom]--;\
00626   graphData.n_B[1][__dom]++;\
00627   EGbitSet(nodeData[__n_id].Ib,__dom);\
00628   nodeData[__n_id].n_in_B++;}
00629 
00630 /* ========================================================================= */
00632 /* ========================================================================= */
00633 static int KPTmakeMoveBHBHc (KPTMove_t const *const cur_move,
00634                              const unsigned int update_flags)
00635 {
00636   /* local variables */
00637   unsigned int n_id = cur_move->n_id;
00638   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00639 
00640   /* update flags if necesary */
00641   if (update_flags && !nodeData[n_id].in_BH)
00642     nodeData[n_id].added_BH = 1U;
00643   /* flip the node in the handle */
00644   KPTmoveBH (n_id);
00645   /* we have to compute every move */
00646   for (; e_it; e_it = e_it->next)
00647   {
00648     /* we just flip BF */
00649     edgeData[KPTgetEdgeId (e_it)].num.in_BF++;
00650   }                             /* end loop through all incident edges */
00651   return 0;
00652 }
00653 
00654 /* ========================================================================= */
00656 /* ========================================================================= */
00657 #define KPTmakeMoveBHcBH(__id,__val) KPTmakeMoveBHBHc(__id,__val)
00658 
00659 /* ========================================================================= */
00661 /* ========================================================================= */
00662 static int KPTmakeMoveAHAHc (KPTMove_t const *const cur_move,
00663                              const unsigned int update_flags)
00664 {
00665   /* local variables */
00666   unsigned int n_id = cur_move->n_id;
00667   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00668 
00669   /* update flags if necesary */
00670   if (update_flags && !nodeData[n_id].in_AH)
00671     nodeData[n_id].added_AH = 1U;
00672   /* flip the node in the handle */
00673   KPTmoveAH (n_id);
00674   /* we have to compute every move */
00675   for (; e_it; e_it = e_it->next)
00676   {
00677     /* we just flip AF */
00678     edgeData[KPTgetEdgeId (e_it)].num.in_AF++;
00679   }                             /* end loop through all incident edges */
00680   return 0;
00681 }
00682 
00683 /* ========================================================================= */
00685 /* ========================================================================= */
00686 #define KPTmakeMoveAHcAH(__id,__val) KPTmakeMoveAHAHc(__id,__val)
00687 
00688 /* ========================================================================= */
00691 /* ========================================================================= */
00692 static int KPTmakeMoveAHAHcBHBHc (KPTMove_t const *const cur_move,
00693                                   const unsigned int update_flags)
00694 {
00695   /* local variables */
00696   unsigned int n_id = cur_move->n_id;
00697   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00698 
00699   /* update flags if necesary */
00700   if (update_flags && !nodeData[n_id].in_AH)
00701     nodeData[n_id].added_AH = 1U;
00702   if (update_flags && !nodeData[n_id].in_BH)
00703     nodeData[n_id].added_BH = 1U;
00704   /* flip the node in the handle */
00705   KPTmoveBH (n_id);
00706   KPTmoveAH (n_id);
00707   /* we have to compute every move */
00708   for (; e_it; e_it = e_it->next)
00709   {
00710     /* we just flip AF */
00711     edgeData[KPTgetEdgeId (e_it)].num.in_AF++;
00712     /* we just flip BF */
00713     edgeData[KPTgetEdgeId (e_it)].num.in_BF++;
00714   }                             /* end loop through all incident edges */
00715   return 0;
00716 }
00717 
00718 /* ========================================================================= */
00720 /* ========================================================================= */
00721 #define KPTmakeMoveAHAHcBHcBH(__id,__val) KPTmakeMoveAHAHcBHBHc(__id,__val)
00722 
00723 /* ========================================================================= */
00725 /* ========================================================================= */
00726 #define KPTmakeMoveAHcAHBHBHc(__id,__val) KPTmakeMoveAHAHcBHBHc(__id,__val)
00727 
00728 /* ========================================================================= */
00730 /* ========================================================================= */
00731 #define KPTmakeMoveAHcAHBHcBH(__id,__val) KPTmakeMoveAHAHcBHBHc(__id,__val)
00732 
00733 /* ========================================================================= */
00735 /* ========================================================================= */
00736 static int KPTmakeMoveAcBTc (const KPTMove_t * const cur_move)
00737 {
00738   /* local variables */
00739   unsigned int e_id,
00740     no_id,
00741     pos,
00742     n_id = cur_move->n_id,
00743     dom = cur_move->dom;
00744   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00745 
00746   /* change the node from AcB to Tc */
00747   EGbitUnset (nodeData[n_id].Ib, dom);
00748   EGbitUnset (nodeData[n_id].It, dom);
00749   graphData.n_A[0][dom]--;
00750   graphData.n_B[1][dom]--;
00751   graphData.n_Tc[dom]++;
00752   nodeData[n_id].n_in_B--;
00753   nodeData[n_id].n_in_T--;
00754   graphData.n_AdB[0][dom]--;
00755   /* we have to compute every move */
00756   for (; e_it; e_it = e_it->next)
00757   {
00758     e_id = KPTgetEdgeId (e_it);
00759     no_id = KPTgetOtherEndId (n_id, e_it);
00760     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
00761       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
00762       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
00763     switch (pos)
00764     {
00765     case 5U:
00766       /* in this case, the only change is that we have to pay for this edge in
00767        * Delta(T) */
00768       edgeData[e_id].num.n_dT++;
00769       break;
00770     case 3U:
00771       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
00772        * one E(B:Bc) and flip BF */
00773       edgeData[e_id].num.n_dT++;
00774       edgeData[e_id].num.n_AtoAc--;
00775       edgeData[e_id].num.in_AF++;
00776       edgeData[e_id].num.n_BtoBc--;
00777       edgeData[e_id].num.in_BF++;
00778       break;
00779     case 1U:
00780       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
00781       edgeData[e_id].num.n_dT++;
00782       edgeData[e_id].num.n_BtoBc--;
00783       edgeData[e_id].num.in_BF++;
00784       break;
00785     case 7U:
00786       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
00787       edgeData[e_id].num.n_dT++;
00788       edgeData[e_id].num.n_AtoAc--;
00789       edgeData[e_id].num.in_AF++;
00790       break;
00791     case 0U:
00792       /* in this case we save one Delta(T) */
00793       edgeData[e_id].num.n_dT--;
00794       break;
00795     default:
00796       EXIT (1, "This should not happen, value %u", pos);
00797     }                           /* end switch */
00798   }                             /* end loop through all incident edges */
00799   return 0;
00800 }
00801 
00802 /* ========================================================================= */
00804 /* ========================================================================= */
00805 static int KPTmakeMoveABcTc (const KPTMove_t * const cur_move)
00806 {
00807   /* local variables */
00808   unsigned int e_id,
00809     no_id,
00810     pos,
00811     n_id = cur_move->n_id,
00812     dom = cur_move->dom;
00813   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00814 
00815   /* change the node from ABc to Tc */
00816   EGbitUnset (nodeData[n_id].Ia, dom);
00817   EGbitUnset (nodeData[n_id].It, dom);
00818   graphData.n_A[1][dom]--;
00819   graphData.n_B[0][dom]--;
00820   graphData.n_Tc[dom]++;
00821   nodeData[n_id].n_in_A--;
00822   nodeData[n_id].n_in_T--;
00823   graphData.n_AdB[0][dom]--;
00824   /* we have to compute every move */
00825   for (; e_it; e_it = e_it->next)
00826   {
00827     e_id = KPTgetEdgeId (e_it);
00828     no_id = KPTgetOtherEndId (n_id, e_it);
00829     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
00830       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
00831       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
00832     switch (pos)
00833     {
00834     case 3U:
00835       /* in this case, the only change is that we have to pay for this edge in
00836        * Delta(T) */
00837       edgeData[e_id].num.n_dT++;
00838       break;
00839     case 5U:
00840       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
00841        * one E(B:Bc) and flip BF */
00842       edgeData[e_id].num.n_dT++;
00843       edgeData[e_id].num.n_AtoAc--;
00844       edgeData[e_id].num.in_AF++;
00845       edgeData[e_id].num.n_BtoBc--;
00846       edgeData[e_id].num.in_BF++;
00847       break;
00848     case 7U:
00849       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
00850       edgeData[e_id].num.n_dT++;
00851       edgeData[e_id].num.n_BtoBc--;
00852       edgeData[e_id].num.in_BF++;
00853       break;
00854     case 1U:
00855       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
00856       edgeData[e_id].num.n_dT++;
00857       edgeData[e_id].num.n_AtoAc--;
00858       edgeData[e_id].num.in_AF++;
00859       break;
00860     case 0U:
00861       /* in this case we save one Delta(T) */
00862       edgeData[e_id].num.n_dT--;
00863       break;
00864     default:
00865       EXIT (1, "This should not happen, value %u", pos);
00866     }                           /* end switch */
00867   }                             /* end loop through all incident edges */
00868   return 0;
00869 }
00870 
00871 /* ========================================================================= */
00873 /* ========================================================================= */
00874 static int KPTmakeMoveAcBcTc (const KPTMove_t * const cur_move)
00875 {
00876   /* local variables */
00877   unsigned int e_id,
00878     no_id,
00879     pos,
00880     n_id = cur_move->n_id,
00881     dom = cur_move->dom;
00882   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00883 
00884   /* change the node from AcBc to Tc */
00885   EGbitUnset (nodeData[n_id].It, dom);
00886   graphData.n_A[0][dom]--;
00887   graphData.n_B[0][dom]--;
00888   graphData.n_Tc[dom]++;
00889   nodeData[n_id].n_in_T--;
00890   graphData.n_AdB[1][dom]--;
00891   EGbitUnset (nodeData[n_id].Iadb, dom);
00892   /* we have to compute every move */
00893   for (; e_it; e_it = e_it->next)
00894   {
00895     e_id = KPTgetEdgeId (e_it);
00896     no_id = KPTgetOtherEndId (n_id, e_it);
00897     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
00898       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
00899       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
00900     switch (pos)
00901     {
00902     case 1U:
00903       /* in this case, the only change is that we have to pay for this edge in
00904        * Delta(T) */
00905       edgeData[e_id].num.n_dT++;
00906       break;
00907     case 7U:
00908       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
00909        * one E(B:Bc) and flip BF */
00910       edgeData[e_id].num.n_dT++;
00911       edgeData[e_id].num.n_AtoAc--;
00912       edgeData[e_id].num.in_AF++;
00913       edgeData[e_id].num.n_BtoBc--;
00914       edgeData[e_id].num.in_BF++;
00915       break;
00916     case 5U:
00917       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
00918       edgeData[e_id].num.n_dT++;
00919       edgeData[e_id].num.n_BtoBc--;
00920       edgeData[e_id].num.in_BF++;
00921       break;
00922     case 3U:
00923       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
00924       edgeData[e_id].num.n_dT++;
00925       edgeData[e_id].num.n_AtoAc--;
00926       edgeData[e_id].num.in_AF++;
00927       break;
00928     case 0U:
00929       /* in this case we save one Delta(T) */
00930       edgeData[e_id].num.n_dT--;
00931       break;
00932     default:
00933       EXIT (1, "This should not happen, value %u", pos);
00934     }                           /* end switch */
00935   }                             /* end loop through all incident edges */
00936   return 0;
00937 }
00938 
00939 /* ========================================================================= */
00942 /* ========================================================================= */
00943 static int KPTmakeMoveBBcflipBH (const KPTMove_t * const cur_move,
00944                                  const unsigned int update_flags)
00945 {
00946   /* local variables */
00947   unsigned int e_id,
00948     no_id,
00949     pos,
00950     n_id = cur_move->n_id,
00951     dom = cur_move->dom;
00952   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
00953 
00954   /* update flags if necesary */
00955   if (update_flags)
00956     EGbitSet (nodeData[n_id].flipB, dom);
00957   /* flip the handle and change the node */
00958   KPTmoveBH (n_id);
00959   KPTmoveBBc (n_id, dom);
00960   KPTmoveAdB (n_id, dom);
00961   /* we have to compute every move */
00962   for (; e_it; e_it = e_it->next)
00963   {
00964     e_id = KPTgetEdgeId (e_it);
00965     no_id = KPTgetOtherEndId (n_id, e_it);
00966     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
00967       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
00968     switch (pos)
00969     {
00970     case 0U:
00971       /* in this case, change BH and flip BF  */
00972       edgeData[e_id].num.in_BF++;
00973       break;
00974     case 1U:
00975       /* in this case we save one E(B:Bc) and double flip BF and change BH */
00976       edgeData[e_id].num.n_BtoBc--;
00977       break;
00978     case 3U:
00979       /* in this case we pay one E(B:Bc) and double flip BF and change BH */
00980       edgeData[e_id].num.n_BtoBc++;
00981       break;
00982     default:
00983       EXIT (1, "This should not happen, value %u", pos);
00984     }                           /* end switch */
00985   }                             /* end loop through all incident edges */
00986   return 0;
00987 }
00988 
00989 /* ========================================================================= */
00992 /* ========================================================================= */
00993 static int KPTmakeMoveBcBflipBH (const KPTMove_t * const cur_move,
00994                                  const unsigned int update_flags)
00995 {
00996   /* local variables */
00997   unsigned int e_id,
00998     no_id,
00999     pos,
01000     n_id = cur_move->n_id,
01001     dom = cur_move->dom;
01002   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01003 
01004   /* update flags if necesary */
01005   if (update_flags)
01006     EGbitSet (nodeData[n_id].flipBc, dom);
01007   /* flip the handle and change the node */
01008   KPTmoveBH (n_id);
01009   KPTmoveBcB (n_id, dom);
01010   KPTmoveAdB (n_id, dom);
01011   /* we have to compute every move */
01012   for (; e_it; e_it = e_it->next)
01013   {
01014     e_id = KPTgetEdgeId (e_it);
01015     no_id = KPTgetOtherEndId (n_id, e_it);
01016     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01017       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
01018     switch (pos)
01019     {
01020     case 0U:
01021       /* in this case, change BH and flip BF  */
01022       edgeData[e_id].num.in_BF++;
01023       break;
01024     case 3U:
01025       /* in this case we save one E(B:Bc) and double flip BF and change BH */
01026       edgeData[e_id].num.n_BtoBc--;
01027       break;
01028     case 1U:
01029       /* in this case we pay one E(B:Bc) and double flip BF and change BH */
01030       edgeData[e_id].num.n_BtoBc++;
01031       break;
01032     default:
01033       EXIT (1, "This should not happen, value %u", pos);
01034     }                           /* end switch */
01035   }                             /* end loop through all incident edges */
01036   return 0;
01037 }
01038 
01039 /* ========================================================================= */
01042 /* ========================================================================= */
01043 static int KPTmakeMoveAAcflipAH (const KPTMove_t * const cur_move,
01044                                  const unsigned int update_flags)
01045 {
01046   /* local variables */
01047   unsigned int e_id,
01048     no_id,
01049     pos,
01050     n_id = cur_move->n_id,
01051     dom = cur_move->dom;
01052   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01053   /* update flags if necesary */
01054   if (update_flags)
01055     EGbitSet (nodeData[n_id].flipA, dom);
01056   /* flip the handle and change the node */
01057   KPTmoveAH (n_id);
01058   KPTmoveAAc (n_id, dom);
01059   KPTmoveAdB (n_id, dom);
01060   /* we have to compute every move */
01061   for (; e_it; e_it = e_it->next)
01062   {
01063     e_id = KPTgetEdgeId (e_it);
01064     no_id = KPTgetOtherEndId (n_id, e_it);
01065     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01066       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
01067     switch (pos)
01068     {
01069     case 0U:
01070       /* in this case, change AH and flip AF  */
01071       edgeData[e_id].num.in_AF++;
01072       break;
01073     case 1U:
01074       /* in this case we save one E(A:Ac) and double flip AF and change AH */
01075       edgeData[e_id].num.n_AtoAc--;
01076       break;
01077     case 3U:
01078       /* in this case we pay one E(A:Ac) and double flip AF and change AH */
01079       edgeData[e_id].num.n_AtoAc++;
01080       break;
01081     default:
01082       EXIT (1, "This should not happen, value %u", pos);
01083     }                           /* end switch */
01084   }                             /* end loop through all incident edges */
01085   return 0;
01086 }
01087 
01088 /* ========================================================================= */
01091 /* ========================================================================= */
01092 static int KPTmakeMoveAcAflipAH (const KPTMove_t * const cur_move,
01093                                  const unsigned int update_flags)
01094 {
01095   /* local variables */
01096   unsigned int e_id,
01097     no_id,
01098     pos,
01099     n_id = cur_move->n_id,
01100     dom = cur_move->dom;
01101   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01102 
01103   /* update flags if necesary */
01104   if (update_flags)
01105     EGbitSet (nodeData[n_id].flipAc, dom);
01106   /* flip the handle and change the node */
01107   KPTmoveAH (n_id);
01108   KPTmoveAcA (n_id, dom);
01109   KPTmoveAdB (n_id, dom);
01110   /* we have to compute every move */
01111   for (; e_it; e_it = e_it->next)
01112   {
01113     e_id = KPTgetEdgeId (e_it);
01114     no_id = KPTgetOtherEndId (n_id, e_it);
01115     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01116       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
01117     switch (pos)
01118     {
01119     case 0U:
01120       /* in this case, change AH and flip AF  */
01121       edgeData[e_id].num.in_AF++;
01122       break;
01123     case 3U:
01124       /* in this case we save one E(A:Ac) and double flip AF and change AH */
01125       edgeData[e_id].num.n_AtoAc--;
01126       break;
01127     case 1U:
01128       /* in this case we pay one E(A:Ac) and double flip AF and change AH */
01129       edgeData[e_id].num.n_AtoAc++;
01130       break;
01131     default:
01132       EXIT (1, "This should not happen, value %u", pos);
01133     }                           /* end switch */
01134   }                             /* end loop through all incident edges */
01135   return 0;
01136 }
01137 
01138 /* ========================================================================= */
01140 /* ========================================================================= */
01141 static int KPTmakeMoveBBc (const KPTMove_t * const cur_move,
01142                            const unsigned int update_flags)
01143 {
01144   /* local variables */
01145   unsigned int e_id,
01146     no_id,
01147     pos,
01148     n_id = cur_move->n_id,
01149     dom = cur_move->dom;
01150   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01151 
01152   /* update flags if necesary */
01153   if (update_flags)
01154     EGbitSet (nodeData[n_id].flipB, dom);
01155   /* change the node */
01156   KPTmoveBBc (n_id, dom);
01157   KPTmoveAdB (n_id, dom);
01158   /* we have to compute every move */
01159   for (; e_it; e_it = e_it->next)
01160   {
01161     e_id = KPTgetEdgeId (e_it);
01162     no_id = KPTgetOtherEndId (n_id, e_it);
01163     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01164       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
01165     switch (pos)
01166     {
01167     case 0U:
01168       /* in this case, nothing happen  */
01169       break;
01170     case 1U:
01171       /* in this case we save one E(B:Bc) and flip AF */
01172       edgeData[e_id].num.in_BF++;
01173       edgeData[e_id].num.n_BtoBc--;
01174       break;
01175     case 3U:
01176       /* in this case we pay one E(B:Bc) and flip AF */
01177       edgeData[e_id].num.in_BF++;
01178       edgeData[e_id].num.n_BtoBc++;
01179       break;
01180     default:
01181       EXIT (1, "This should not happen, value %u", pos);
01182     }                           /* end switch */
01183   }                             /* end loop through all incident edges */
01184   return 0;
01185 }
01186 
01187 /* ========================================================================= */
01189 /* ========================================================================= */
01190 static int KPTmakeMoveBcB (const KPTMove_t * const cur_move,
01191                            const unsigned int update_flags)
01192 {
01193   /* local variables */
01194   unsigned int e_id,
01195     no_id,
01196     pos,
01197     n_id = cur_move->n_id,
01198     dom = cur_move->dom;
01199   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01200 
01201   /* update flags if necesary */
01202   if (update_flags)
01203     EGbitSet (nodeData[n_id].flipBc, dom);
01204   /* flip the handle and change the node */
01205   KPTmoveBcB (n_id, dom);
01206   KPTmoveAdB (n_id, dom);
01207   /* we have to compute every move */
01208   for (; e_it; e_it = e_it->next)
01209   {
01210     e_id = KPTgetEdgeId (e_it);
01211     no_id = KPTgetOtherEndId (n_id, e_it);
01212     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01213       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
01214     switch (pos)
01215     {
01216     case 0U:
01217       /* in this case, nothing happen  */
01218       break;
01219     case 3U:
01220       /* in this case we save one E(B:Bc) and flip AF */
01221       edgeData[e_id].num.in_BF++;
01222       edgeData[e_id].num.n_BtoBc--;
01223       break;
01224     case 1U:
01225       /* in this case we pay one E(B:Bc) and flip AF */
01226       edgeData[e_id].num.in_BF++;
01227       edgeData[e_id].num.n_BtoBc++;
01228       break;
01229     default:
01230       EXIT (1, "This should not happen, value %u", pos);
01231     }                           /* end switch */
01232   }                             /* end loop through all incident edges */
01233   return 0;
01234 }
01235 
01236 
01237 /* ========================================================================= */
01239 /* ========================================================================= */
01240 static int KPTmakeMoveAAc (const KPTMove_t * const cur_move,
01241                            const unsigned int update_flags)
01242 {
01243   /* local variables */
01244   unsigned int e_id,
01245     no_id,
01246     pos,
01247     n_id = cur_move->n_id,
01248     dom = cur_move->dom;
01249   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01250   /* update flags if necesary */
01251   if (update_flags)
01252     EGbitSet (nodeData[n_id].flipA, dom);
01253   /* flip the handle and change the node */
01254   KPTmoveAAc (n_id, dom);
01255   KPTmoveAdB (n_id, dom);
01256   /* we have to compute every move */
01257   for (; e_it; e_it = e_it->next)
01258   {
01259     e_id = KPTgetEdgeId (e_it);
01260     no_id = KPTgetOtherEndId (n_id, e_it);
01261     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01262       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
01263     switch (pos)
01264     {
01265     case 0U:
01266       /* in this case, nothing happen  */
01267       break;
01268     case 1U:
01269       /* in this case we save one E(A:Ac) and flip AF */
01270       edgeData[e_id].num.in_AF++;
01271       edgeData[e_id].num.n_AtoAc--;
01272       break;
01273     case 3U:
01274       /* in this case we pay one E(A:Ac) and flip AF */
01275       edgeData[e_id].num.in_AF++;
01276       edgeData[e_id].num.n_AtoAc++;
01277       break;
01278     default:
01279       EXIT (1, "This should not happen, value %u", pos);
01280     }                           /* end switch */
01281   }                             /* end loop through all incident edges */
01282   return 0;
01283 }
01284 
01285 /* ========================================================================= */
01287 /* ========================================================================= */
01288 static int KPTmakeMoveAcA (const KPTMove_t * const cur_move,
01289                            const unsigned int update_flags)
01290 {
01291   /* local variables */
01292   unsigned int e_id,
01293     no_id,
01294     pos,
01295     n_id = cur_move->n_id,
01296     dom = cur_move->dom;
01297   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01298 
01299   /* update flags if necesary */
01300   if (update_flags)
01301     EGbitSet (nodeData[n_id].flipAc, dom);
01302   /* flip the handle and change the node */
01303   KPTmoveAcA (n_id, dom);
01304   KPTmoveAdB (n_id, dom);
01305   /* we have to compute every move */
01306   for (; e_it; e_it = e_it->next)
01307   {
01308     e_id = KPTgetEdgeId (e_it);
01309     no_id = KPTgetOtherEndId (n_id, e_it);
01310     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01311       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
01312     switch (pos)
01313     {
01314     case 0U:
01315       /* in this case, nothing happen  */
01316       break;
01317     case 3U:
01318       /* in this case we save one E(A:Ac) and flip AF */
01319       edgeData[e_id].num.in_AF++;
01320       edgeData[e_id].num.n_AtoAc--;
01321       break;
01322     case 1U:
01323       /* in this case we pay one E(A:Ac) and flip AF */
01324       edgeData[e_id].num.in_AF++;
01325       edgeData[e_id].num.n_AtoAc++;
01326       break;
01327     default:
01328       EXIT (1, "This should not happen, value %u", pos);
01329     }                           /* end switch */
01330   }                             /* end loop through all incident edges */
01331   return 0;
01332 }
01333 
01334 /* ========================================================================= */
01337 /* ========================================================================= */
01338 static int KPTmakeMoveAcABBc (const KPTMove_t * const cur_move,
01339                               const unsigned int update_flags)
01340 {
01341   /* local variables */
01342   unsigned int e_id,
01343     no_id,
01344     pos,
01345     n_id = cur_move->n_id,
01346     dom = cur_move->dom;
01347   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01348 
01349   /* update flags if necesary */
01350   if (update_flags)
01351   {
01352     EGbitSet (nodeData[n_id].flipAc, dom);
01353     EGbitSet (nodeData[n_id].flipB, dom);
01354   }
01355   /* flip the handle and change the node */
01356   KPTmoveAcA (n_id, dom);
01357   KPTmoveBBc (n_id, dom);
01358 
01359   /* we have to compute every move */
01360   for (; e_it; e_it = e_it->next)
01361   {
01362     e_id = KPTgetEdgeId (e_it);
01363     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
01364     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01365       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01366       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01367     switch (pos)
01368     {
01369     case 0U:
01370       /* in this case, nothing happen */
01371       break;
01372     case 3U:
01373       /* in this case we save one E(A:Ac) and flip AF, save 
01374        * one E(B:Bc) and flip BF */
01375       edgeData[e_id].num.in_AF++;
01376       edgeData[e_id].num.in_BF++;
01377       edgeData[e_id].num.n_AtoAc--;
01378       edgeData[e_id].num.n_BtoBc--;
01379       break;
01380     case 1U:
01381       /* in this case we pay one E(A:Ac) and flip AF, save 
01382        * one E(B:Bc) and flip BF */
01383       edgeData[e_id].num.in_AF++;
01384       edgeData[e_id].num.in_BF++;
01385       edgeData[e_id].num.n_AtoAc++;
01386       edgeData[e_id].num.n_BtoBc--;
01387       break;
01388     case 7U:
01389       /* in this case we save one E(A:Ac) and flip AF, pay 
01390        * one E(B:Bc) and flip BF */
01391       edgeData[e_id].num.in_AF++;
01392       edgeData[e_id].num.in_BF++;
01393       edgeData[e_id].num.n_AtoAc--;
01394       edgeData[e_id].num.n_BtoBc++;
01395       break;
01396     case 5U:
01397       /* in this case we pay one E(A:Ac) and flip AF, pay 
01398        * one E(B:Bc) and flip BF */
01399       edgeData[e_id].num.in_AF++;
01400       edgeData[e_id].num.in_BF++;
01401       edgeData[e_id].num.n_AtoAc++;
01402       edgeData[e_id].num.n_BtoBc++;
01403       break;
01404     default:
01405       EXIT (1, "This should not happen, value %u", pos);
01406     }                           /* end switch */
01407   }                             /* end loop through all incident edges */
01408   return 0;
01409 }
01410 
01411 /* ========================================================================= */
01414 /* ========================================================================= */
01415 static int KPTmakeMoveAAcBcB (const KPTMove_t * const cur_move,
01416                               const unsigned int update_flags)
01417 {
01418   /* local variables */
01419   unsigned int e_id,
01420     no_id,
01421     pos,
01422     n_id = cur_move->n_id,
01423     dom = cur_move->dom;
01424   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01425 
01426   /* update flags if necesary */
01427   if (update_flags)
01428   {
01429     EGbitSet (nodeData[n_id].flipA, dom);
01430     EGbitSet (nodeData[n_id].flipBc, dom);
01431   }
01432   /* flip the handle and change the node */
01433   KPTmoveAAc (n_id, dom);
01434   KPTmoveBcB (n_id, dom);
01435 
01436   /* we have to compute every move */
01437   for (; e_it; e_it = e_it->next)
01438   {
01439     e_id = KPTgetEdgeId (e_it);
01440     no_id = KPTgetOtherEndId (n_id, e_it);
01441     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01442       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01443       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01444     switch (pos)
01445     {
01446     case 0U:
01447       /* in this case, nothing happen */
01448       break;
01449     case 5U:
01450       /* in this case we save one E(A:Ac) and flip AF, save 
01451        * one E(B:Bc) and flip BF */
01452       edgeData[e_id].num.in_AF++;
01453       edgeData[e_id].num.in_BF++;
01454       edgeData[e_id].num.n_AtoAc--;
01455       edgeData[e_id].num.n_BtoBc--;
01456       break;
01457     case 7U:
01458       /* in this case we pay one E(A:Ac) and flip AF, save 
01459        * one E(B:Bc) and flip BF */
01460       edgeData[e_id].num.in_AF++;
01461       edgeData[e_id].num.in_BF++;
01462       edgeData[e_id].num.n_AtoAc++;
01463       edgeData[e_id].num.n_BtoBc--;
01464       break;
01465     case 1U:
01466       /* in this case we save one E(A:Ac) and flip AF, pay 
01467        * one E(B:Bc) and flip BF */
01468       edgeData[e_id].num.in_AF++;
01469       edgeData[e_id].num.in_BF++;
01470       edgeData[e_id].num.n_AtoAc--;
01471       edgeData[e_id].num.n_BtoBc++;
01472       break;
01473     case 3U:
01474       /* in this case we pay one E(A:Ac) and flip AF, pay 
01475        * one E(B:Bc) and flip BF */
01476       edgeData[e_id].num.in_AF++;
01477       edgeData[e_id].num.in_BF++;
01478       edgeData[e_id].num.n_AtoAc++;
01479       edgeData[e_id].num.n_BtoBc++;
01480       break;
01481     default:
01482       EXIT (1, "This should not happen, value %u", pos);
01483     }                           /* end switch */
01484   }                             /* end loop through all incident edges */
01485   return 0;
01486 }
01487 
01488 /* ========================================================================= */
01491 /* ========================================================================= */
01492 static int KPTmakeMoveAcABcB (const KPTMove_t * const cur_move,
01493                               const unsigned int update_flags)
01494 {
01495   /* local variables */
01496   unsigned int e_id,
01497     no_id,
01498     pos,
01499     n_id = cur_move->n_id,
01500     dom = cur_move->dom;
01501   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01502 
01503   /* update flags if necesary */
01504   if (update_flags)
01505   {
01506     EGbitSet (nodeData[n_id].flipAc, dom);
01507     EGbitSet (nodeData[n_id].flipBc, dom);
01508   }
01509   /* flip the handle and change the node */
01510   KPTmoveAcA (n_id, dom);
01511   KPTmoveBcB (n_id, dom);
01512 
01513   /* we have to compute every move */
01514   for (; e_it; e_it = e_it->next)
01515   {
01516     e_id = KPTgetEdgeId (e_it);
01517     no_id = KPTgetOtherEndId (n_id, e_it);
01518     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01519       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01520       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01521     switch (pos)
01522     {
01523     case 0U:
01524       /* in this case, nothing happen */
01525       break;
01526     case 7U:
01527       /* in this case we save one E(A:Ac) and flip AF, save 
01528        * one E(B:Bc) and flip BF */
01529       edgeData[e_id].num.in_AF++;
01530       edgeData[e_id].num.in_BF++;
01531       edgeData[e_id].num.n_AtoAc--;
01532       edgeData[e_id].num.n_BtoBc--;
01533       break;
01534     case 5U:
01535       /* in this case we pay one E(A:Ac) and flip AF, save 
01536        * one E(B:Bc) and flip BF */
01537       edgeData[e_id].num.in_AF++;
01538       edgeData[e_id].num.in_BF++;
01539       edgeData[e_id].num.n_AtoAc++;
01540       edgeData[e_id].num.n_BtoBc--;
01541       break;
01542     case 3U:
01543       /* in this case we save one E(A:Ac) and flip AF, pay 
01544        * one E(B:Bc) and flip BF */
01545       edgeData[e_id].num.in_AF++;
01546       edgeData[e_id].num.in_BF++;
01547       edgeData[e_id].num.n_AtoAc--;
01548       edgeData[e_id].num.n_BtoBc++;
01549       break;
01550     case 1U:
01551       /* in this case we pay one E(A:Ac) and flip AF, pay 
01552        * one E(B:Bc) and flip BF */
01553       edgeData[e_id].num.in_AF++;
01554       edgeData[e_id].num.in_BF++;
01555       edgeData[e_id].num.n_AtoAc++;
01556       edgeData[e_id].num.n_BtoBc++;
01557       break;
01558     default:
01559       EXIT (1, "This should not happen, value %u", pos);
01560     }                           /* end switch */
01561   }                             /* end loop through all incident edges */
01562   return 0;
01563 }
01564 
01565 /* ========================================================================= */
01568 /* ========================================================================= */
01569 static int KPTmakeMoveAAcBBc (const KPTMove_t * const cur_move,
01570                               const unsigned int update_flags)
01571 {
01572   /* local variables */
01573   unsigned int e_id,
01574     no_id,
01575     pos,
01576     n_id = cur_move->n_id,
01577     dom = cur_move->dom;
01578   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01579 
01580   /* update flags if necesary */
01581   if (update_flags)
01582   {
01583     EGbitSet (nodeData[n_id].flipA, dom);
01584     EGbitSet (nodeData[n_id].flipB, dom);
01585   }
01586   /* flip the handle and change the node */
01587   KPTmoveAAc (n_id, dom);
01588   KPTmoveBBc (n_id, dom);
01589 
01590   /* we have to compute every move */
01591   for (; e_it; e_it = e_it->next)
01592   {
01593     e_id = KPTgetEdgeId (e_it);
01594     no_id = KPTgetOtherEndId (n_id, e_it);
01595     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01596       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01597       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01598     switch (pos)
01599     {
01600     case 0U:
01601       /* in this case, nothing happen */
01602       break;
01603     case 1U:
01604       /* in this case we save one E(A:Ac) and flip AF, save 
01605        * one E(B:Bc) and flip BF */
01606       edgeData[e_id].num.in_AF++;
01607       edgeData[e_id].num.in_BF++;
01608       edgeData[e_id].num.n_AtoAc--;
01609       edgeData[e_id].num.n_BtoBc--;
01610       break;
01611     case 3U:
01612       /* in this case we pay one E(A:Ac) and flip AF, save 
01613        * one E(B:Bc) and flip BF */
01614       edgeData[e_id].num.in_AF++;
01615       edgeData[e_id].num.in_BF++;
01616       edgeData[e_id].num.n_AtoAc++;
01617       edgeData[e_id].num.n_BtoBc--;
01618       break;
01619     case 5U:
01620       /* in this case we save one E(A:Ac) and flip AF, pay 
01621        * one E(B:Bc) and flip BF */
01622       edgeData[e_id].num.in_AF++;
01623       edgeData[e_id].num.in_BF++;
01624       edgeData[e_id].num.n_AtoAc--;
01625       edgeData[e_id].num.n_BtoBc++;
01626       break;
01627     case 7U:
01628       /* in this case we pay one E(A:Ac) and flip AF, pay 
01629        * one E(B:Bc) and flip BF */
01630       edgeData[e_id].num.in_AF++;
01631       edgeData[e_id].num.in_BF++;
01632       edgeData[e_id].num.n_AtoAc++;
01633       edgeData[e_id].num.n_BtoBc++;
01634       break;
01635     default:
01636       EXIT (1, "This should not happen, value %u", pos);
01637     }                           /* end switch */
01638   }                             /* end loop through all incident edges */
01639   return 0;
01640 }
01641 
01642 /* ========================================================================= */
01645 /* ========================================================================= */
01646 static int KPTmakeMoveAcABBcflipAH (const KPTMove_t * const cur_move,
01647                                     const unsigned int update_flags)
01648 {
01649   /* local variables */
01650   unsigned int e_id,
01651     no_id,
01652     pos,
01653     n_id = cur_move->n_id,
01654     dom = cur_move->dom;
01655   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01656 
01657   /* update flags if necesary */
01658   if (update_flags)
01659   {
01660     EGbitSet (nodeData[n_id].flipAc, dom);
01661     EGbitSet (nodeData[n_id].flipB, dom);
01662   }
01663   /* flip the handle and change the node */
01664   KPTmoveAcA (n_id, dom);
01665   KPTmoveBBc (n_id, dom);
01666   KPTmoveAH (n_id);
01667 
01668   /* we have to compute every move */
01669   for (; e_it; e_it = e_it->next)
01670   {
01671     e_id = KPTgetEdgeId (e_it);
01672     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
01673     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01674       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01675       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01676     switch (pos)
01677     {
01678     case 0U:
01679       /* in this case, flip AH */
01680       edgeData[e_id].num.in_AF++;
01681       break;
01682     case 3U:
01683       /* in this case we save one E(A:Ac) and double flip AF, save 
01684        * one E(B:Bc) and flip BF */
01685       edgeData[e_id].num.in_BF++;
01686       edgeData[e_id].num.n_AtoAc--;
01687       edgeData[e_id].num.n_BtoBc--;
01688       break;
01689     case 1U:
01690       /* in this case we pay one E(A:Ac) and double flip AF, save 
01691        * one E(B:Bc) and flip BF */
01692       edgeData[e_id].num.in_BF++;
01693       edgeData[e_id].num.n_AtoAc++;
01694       edgeData[e_id].num.n_BtoBc--;
01695       break;
01696     case 7U:
01697       /* in this case we save one E(A:Ac) and double flip AF, pay 
01698        * one E(B:Bc) and flip BF */
01699       edgeData[e_id].num.in_BF++;
01700       edgeData[e_id].num.n_AtoAc--;
01701       edgeData[e_id].num.n_BtoBc++;
01702       break;
01703     case 5U:
01704       /* in this case we pay one E(A:Ac) and double flip AF, pay 
01705        * one E(B:Bc) and flip BF */
01706       edgeData[e_id].num.in_BF++;
01707       edgeData[e_id].num.n_AtoAc++;
01708       edgeData[e_id].num.n_BtoBc++;
01709       break;
01710     default:
01711       EXIT (1, "This should not happen, value %u", pos);
01712     }                           /* end switch */
01713   }                             /* end loop through all incident edges */
01714   return 0;
01715 }
01716 
01717 /* ========================================================================= */
01720 /* ========================================================================= */
01721 static int KPTmakeMoveAAcBcBflipAH (const KPTMove_t * const cur_move,
01722                                     const unsigned int update_flags)
01723 {
01724   /* local variables */
01725   unsigned int e_id,
01726     no_id,
01727     pos,
01728     n_id = cur_move->n_id,
01729     dom = cur_move->dom;
01730   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01731 
01732   /* update flags if necesary */
01733   if (update_flags)
01734   {
01735     EGbitSet (nodeData[n_id].flipA, dom);
01736     EGbitSet (nodeData[n_id].flipBc, dom);
01737   }
01738   /* flip the handle and change the node */
01739   KPTmoveAAc (n_id, dom);
01740   KPTmoveBcB (n_id, dom);
01741   KPTmoveAH (n_id);
01742 
01743   /* we have to compute every move */
01744   for (; e_it; e_it = e_it->next)
01745   {
01746     e_id = KPTgetEdgeId (e_it);
01747     no_id = KPTgetOtherEndId (n_id, e_it);
01748     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01749       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01750       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01751     switch (pos)
01752     {
01753     case 0U:
01754       /* in this case, flip AH */
01755       edgeData[e_id].num.in_AF++;
01756       break;
01757     case 5U:
01758       /* in this case we save one E(A:Ac) and double flip AF, save 
01759        * one E(B:Bc) and flip BF */
01760       edgeData[e_id].num.in_BF++;
01761       edgeData[e_id].num.n_AtoAc--;
01762       edgeData[e_id].num.n_BtoBc--;
01763       break;
01764     case 7U:
01765       /* in this case we pay one E(A:Ac) and double flip AF, save 
01766        * one E(B:Bc) and flip BF */
01767       edgeData[e_id].num.in_BF++;
01768       edgeData[e_id].num.n_AtoAc++;
01769       edgeData[e_id].num.n_BtoBc--;
01770       break;
01771     case 1U:
01772       /* in this case we save one E(A:Ac) and double flip AF, pay 
01773        * one E(B:Bc) and flip BF */
01774       edgeData[e_id].num.in_BF++;
01775       edgeData[e_id].num.n_AtoAc--;
01776       edgeData[e_id].num.n_BtoBc++;
01777       break;
01778     case 3U:
01779       /* in this case we pay one E(A:Ac) and double flip AF, pay 
01780        * one E(B:Bc) and flip BF */
01781       edgeData[e_id].num.in_BF++;
01782       edgeData[e_id].num.n_AtoAc++;
01783       edgeData[e_id].num.n_BtoBc++;
01784       break;
01785     default:
01786       EXIT (1, "This should not happen, value %u", pos);
01787     }                           /* end switch */
01788   }                             /* end loop through all incident edges */
01789   return 0;
01790 }
01791 
01792 /* ========================================================================= */
01795 /* ========================================================================= */
01796 static int KPTmakeMoveAcABcBflipAH (const KPTMove_t * const cur_move,
01797                                     const unsigned int update_flags)
01798 {
01799   /* local variables */
01800   unsigned int e_id,
01801     no_id,
01802     pos,
01803     n_id = cur_move->n_id,
01804     dom = cur_move->dom;
01805   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01806 
01807   /* update flags if necesary */
01808   if (update_flags)
01809   {
01810     EGbitSet (nodeData[n_id].flipAc, dom);
01811     EGbitSet (nodeData[n_id].flipBc, dom);
01812   }
01813   /* flip the handle and change the node */
01814   KPTmoveAcA (n_id, dom);
01815   KPTmoveBcB (n_id, dom);
01816   KPTmoveAH (n_id);
01817 
01818   /* we have to compute every move */
01819   for (; e_it; e_it = e_it->next)
01820   {
01821     e_id = KPTgetEdgeId (e_it);
01822     no_id = KPTgetOtherEndId (n_id, e_it);
01823     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01824       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01825       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01826     switch (pos)
01827     {
01828     case 0U:
01829       /* in this case, flip AH */
01830       edgeData[e_id].num.in_AF++;
01831       break;
01832     case 7U:
01833       /* in this case we save one E(A:Ac) and double flip AF, save 
01834        * one E(B:Bc) and flip BF */
01835       edgeData[e_id].num.in_BF++;
01836       edgeData[e_id].num.n_AtoAc--;
01837       edgeData[e_id].num.n_BtoBc--;
01838       break;
01839     case 5U:
01840       /* in this case we pay one E(A:Ac) and double flip AF, save 
01841        * one E(B:Bc) and flip BF */
01842       edgeData[e_id].num.in_BF++;
01843       edgeData[e_id].num.n_AtoAc++;
01844       edgeData[e_id].num.n_BtoBc--;
01845       break;
01846     case 3U:
01847       /* in this case we save one E(A:Ac) and double flip AF, pay 
01848        * one E(B:Bc) and flip BF */
01849       edgeData[e_id].num.in_BF++;
01850       edgeData[e_id].num.n_AtoAc--;
01851       edgeData[e_id].num.n_BtoBc++;
01852       break;
01853     case 1U:
01854       /* in this case we pay one E(A:Ac) and double flip AF, pay 
01855        * one E(B:Bc) and flip BF */
01856       edgeData[e_id].num.in_BF++;
01857       edgeData[e_id].num.n_AtoAc++;
01858       edgeData[e_id].num.n_BtoBc++;
01859       break;
01860     default:
01861       EXIT (1, "This should not happen, value %u", pos);
01862     }                           /* end switch */
01863   }                             /* end loop through all incident edges */
01864   return 0;
01865 }
01866 
01867 /* ========================================================================= */
01870 /* ========================================================================= */
01871 static int KPTmakeMoveAAcBBcflipAH (const KPTMove_t * const cur_move,
01872                                     const unsigned int update_flags)
01873 {
01874   /* local variables */
01875   unsigned int e_id,
01876     no_id,
01877     pos,
01878     n_id = cur_move->n_id,
01879     dom = cur_move->dom;
01880   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01881 
01882   /* update flags if necesary */
01883   if (update_flags)
01884   {
01885     EGbitSet (nodeData[n_id].flipA, dom);
01886     EGbitSet (nodeData[n_id].flipB, dom);
01887   }
01888   /* flip the handle and change the node */
01889   KPTmoveAAc (n_id, dom);
01890   KPTmoveBBc (n_id, dom);
01891   KPTmoveAH (n_id);
01892 
01893   /* we have to compute every move */
01894   for (; e_it; e_it = e_it->next)
01895   {
01896     e_id = KPTgetEdgeId (e_it);
01897     no_id = KPTgetOtherEndId (n_id, e_it);
01898     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01899       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01900       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01901     switch (pos)
01902     {
01903     case 0U:
01904       /* in this case, flip AH */
01905       edgeData[e_id].num.in_AF++;
01906       break;
01907     case 1U:
01908       /* in this case we save one E(A:Ac) and double flip AF, save 
01909        * one E(B:Bc) and flip BF */
01910       edgeData[e_id].num.in_BF++;
01911       edgeData[e_id].num.n_AtoAc--;
01912       edgeData[e_id].num.n_BtoBc--;
01913       break;
01914     case 3U:
01915       /* in this case we pay one E(A:Ac) and double flip AF, save 
01916        * one E(B:Bc) and flip BF */
01917       edgeData[e_id].num.in_BF++;
01918       edgeData[e_id].num.n_AtoAc++;
01919       edgeData[e_id].num.n_BtoBc--;
01920       break;
01921     case 5U:
01922       /* in this case we save one E(A:Ac) and double flip AF, pay 
01923        * one E(B:Bc) and flip BF */
01924       edgeData[e_id].num.in_BF++;
01925       edgeData[e_id].num.n_AtoAc--;
01926       edgeData[e_id].num.n_BtoBc++;
01927       break;
01928     case 7U:
01929       /* in this case we pay one E(A:Ac) and double flip AF, pay 
01930        * one E(B:Bc) and flip BF */
01931       edgeData[e_id].num.in_BF++;
01932       edgeData[e_id].num.n_AtoAc++;
01933       edgeData[e_id].num.n_BtoBc++;
01934       break;
01935     default:
01936       EXIT (1, "This should not happen, value %u", pos);
01937     }                           /* end switch */
01938   }                             /* end loop through all incident edges */
01939   return 0;
01940 }
01941 
01942 /* ========================================================================= */
01945 /* ========================================================================= */
01946 static int KPTmakeMoveAcABBcflipBH (const KPTMove_t * const cur_move,
01947                                     const unsigned int update_flags)
01948 {
01949   /* local variables */
01950   unsigned int e_id,
01951     no_id,
01952     pos,
01953     n_id = cur_move->n_id,
01954     dom = cur_move->dom;
01955   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
01956 
01957   /* update flags if necesary */
01958   if (update_flags)
01959   {
01960     EGbitSet (nodeData[n_id].flipAc, dom);
01961     EGbitSet (nodeData[n_id].flipB, dom);
01962   }
01963   /* flip the handle and change the node */
01964   KPTmoveAcA (n_id, dom);
01965   KPTmoveBBc (n_id, dom);
01966   KPTmoveBH (n_id);
01967 
01968   /* we have to compute every move */
01969   for (; e_it; e_it = e_it->next)
01970   {
01971     e_id = KPTgetEdgeId (e_it);
01972     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
01973     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
01974       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
01975       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
01976     switch (pos)
01977     {
01978     case 0U:
01979       /* in this case, flip BH */
01980       edgeData[e_id].num.in_BF++;
01981       break;
01982     case 3U:
01983       /* in this case we save one E(A:Ac) and flip AF, save 
01984        * one E(B:Bc) and double flip BF */
01985       edgeData[e_id].num.in_AF++;
01986       edgeData[e_id].num.n_AtoAc--;
01987       edgeData[e_id].num.n_BtoBc--;
01988       break;
01989     case 1U:
01990       /* in this case we pay one E(A:Ac) and flip AF, save 
01991        * one E(B:Bc) and double flip BF */
01992       edgeData[e_id].num.in_AF++;
01993       edgeData[e_id].num.n_AtoAc++;
01994       edgeData[e_id].num.n_BtoBc--;
01995       break;
01996     case 7U:
01997       /* in this case we save one E(A:Ac) and flip AF, pay 
01998        * one E(B:Bc) and double flip BF */
01999       edgeData[e_id].num.in_AF++;
02000       edgeData[e_id].num.n_AtoAc--;
02001       edgeData[e_id].num.n_BtoBc++;
02002       break;
02003     case 5U:
02004       /* in this case we pay one E(A:Ac) and flip AF, pay 
02005        * one E(B:Bc) and double flip BF */
02006       edgeData[e_id].num.in_AF++;
02007       edgeData[e_id].num.n_AtoAc++;
02008       edgeData[e_id].num.n_BtoBc++;
02009       break;
02010     default:
02011       EXIT (1, "This should not happen, value %u", pos);
02012     }                           /* end switch */
02013   }                             /* end loop through all incident edges */
02014   return 0;
02015 }
02016 
02017 /* ========================================================================= */
02020 /* ========================================================================= */
02021 static int KPTmakeMoveAAcBcBflipBH (const KPTMove_t * const cur_move,
02022                                     const unsigned int update_flags)
02023 {
02024   /* local variables */
02025   unsigned int e_id,
02026     no_id,
02027     pos,
02028     n_id = cur_move->n_id,
02029     dom = cur_move->dom;
02030   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02031 
02032   /* update flags if necesary */
02033   if (update_flags)
02034   {
02035     EGbitSet (nodeData[n_id].flipA, dom);
02036     EGbitSet (nodeData[n_id].flipBc, dom);
02037   }
02038   /* flip the handle and change the node */
02039   KPTmoveAAc (n_id, dom);
02040   KPTmoveBcB (n_id, dom);
02041   KPTmoveBH (n_id);
02042 
02043   /* we have to compute every move */
02044   for (; e_it; e_it = e_it->next)
02045   {
02046     e_id = KPTgetEdgeId (e_it);
02047     no_id = KPTgetOtherEndId (n_id, e_it);
02048     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02049       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02050       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02051     switch (pos)
02052     {
02053     case 0U:
02054       /* in this case, flip BH */
02055       edgeData[e_id].num.in_BF++;
02056       break;
02057     case 5U:
02058       /* in this case we save one E(A:Ac) and flip AF, save 
02059        * one E(B:Bc) and double flip BF */
02060       edgeData[e_id].num.in_AF++;
02061       edgeData[e_id].num.n_AtoAc--;
02062       edgeData[e_id].num.n_BtoBc--;
02063       break;
02064     case 7U:
02065       /* in this case we pay one E(A:Ac) and flip AF, save 
02066        * one E(B:Bc) and double flip BF */
02067       edgeData[e_id].num.in_AF++;
02068       edgeData[e_id].num.n_AtoAc++;
02069       edgeData[e_id].num.n_BtoBc--;
02070       break;
02071     case 1U:
02072       /* in this case we save one E(A:Ac) and flip AF, pay 
02073        * one E(B:Bc) and double flip BF */
02074       edgeData[e_id].num.in_AF++;
02075       edgeData[e_id].num.n_AtoAc--;
02076       edgeData[e_id].num.n_BtoBc++;
02077       break;
02078     case 3U:
02079       /* in this case we pay one E(A:Ac) and flip AF, pay 
02080        * one E(B:Bc) and double flip BF */
02081       edgeData[e_id].num.in_AF++;
02082       edgeData[e_id].num.n_AtoAc++;
02083       edgeData[e_id].num.n_BtoBc++;
02084       break;
02085     default:
02086       EXIT (1, "This should not happen, value %u", pos);
02087     }                           /* end switch */
02088   }                             /* end loop through all incident edges */
02089   return 0;
02090 }
02091 
02092 /* ========================================================================= */
02095 /* ========================================================================= */
02096 static int KPTmakeMoveAcABcBflipBH (const KPTMove_t * const cur_move,
02097                                     const unsigned int update_flags)
02098 {
02099   /* local variables */
02100   unsigned int e_id,
02101     no_id,
02102     pos,
02103     n_id = cur_move->n_id,
02104     dom = cur_move->dom;
02105   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02106 
02107   /* update flags if necesary */
02108   if (update_flags)
02109   {
02110     EGbitSet (nodeData[n_id].flipAc, dom);
02111     EGbitSet (nodeData[n_id].flipBc, dom);
02112   }
02113   /* flip the handle and change the node */
02114   KPTmoveAcA (n_id, dom);
02115   KPTmoveBcB (n_id, dom);
02116   KPTmoveBH (n_id);
02117 
02118   /* we have to compute every move */
02119   for (; e_it; e_it = e_it->next)
02120   {
02121     e_id = KPTgetEdgeId (e_it);
02122     no_id = KPTgetOtherEndId (n_id, e_it);
02123     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02124       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02125       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02126     switch (pos)
02127     {
02128     case 0U:
02129       /* in this case, flip BH */
02130       edgeData[e_id].num.in_BF++;
02131       break;
02132     case 7U:
02133       /* in this case we save one E(A:Ac) and double flip BF, save 
02134        * one E(B:Bc) and flip AF */
02135       edgeData[e_id].num.in_AF++;
02136       edgeData[e_id].num.n_AtoAc--;
02137       edgeData[e_id].num.n_BtoBc--;
02138       break;
02139     case 5U:
02140       /* in this case we pay one E(A:Ac) and double flip BF, save 
02141        * one E(B:Bc) and flip AF */
02142       edgeData[e_id].num.in_AF++;
02143       edgeData[e_id].num.n_AtoAc++;
02144       edgeData[e_id].num.n_BtoBc--;
02145       break;
02146     case 3U:
02147       /* in this case we save one E(A:Ac) and double flip BF, pay 
02148        * one E(B:Bc) and flip AF */
02149       edgeData[e_id].num.in_AF++;
02150       edgeData[e_id].num.n_AtoAc--;
02151       edgeData[e_id].num.n_BtoBc++;
02152       break;
02153     case 1U:
02154       /* in this case we pay one E(A:Ac) and double flip BF, pay 
02155        * one E(B:Bc) and flip AF */
02156       edgeData[e_id].num.in_AF++;
02157       edgeData[e_id].num.n_AtoAc++;
02158       edgeData[e_id].num.n_BtoBc++;
02159       break;
02160     default:
02161       EXIT (1, "This should not happen, value %u", pos);
02162     }                           /* end switch */
02163   }                             /* end loop through all incident edges */
02164   return 0;
02165 }
02166 
02167 /* ========================================================================= */
02170 /* ========================================================================= */
02171 static int KPTmakeMoveAAcBBcflipBH (const KPTMove_t * const cur_move,
02172                                     const unsigned int update_flags)
02173 {
02174   /* local variables */
02175   unsigned int e_id,
02176     no_id,
02177     pos,
02178     n_id = cur_move->n_id,
02179     dom = cur_move->dom;
02180   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02181 
02182   /* update flags if necesary */
02183   if (update_flags)
02184   {
02185     EGbitSet (nodeData[n_id].flipA, dom);
02186     EGbitSet (nodeData[n_id].flipB, dom);
02187   }
02188   /* flip the handle and change the node */
02189   KPTmoveAAc (n_id, dom);
02190   KPTmoveBBc (n_id, dom);
02191   KPTmoveBH (n_id);
02192 
02193   /* we have to compute every move */
02194   for (; e_it; e_it = e_it->next)
02195   {
02196     e_id = KPTgetEdgeId (e_it);
02197     no_id = KPTgetOtherEndId (n_id, e_it);
02198     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02199       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02200       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02201     switch (pos)
02202     {
02203     case 0U:
02204       /* in this case, flip BH */
02205       edgeData[e_id].num.in_BF++;
02206       break;
02207     case 1U:
02208       /* in this case we save one E(A:Ac) and double flip BF, save 
02209        * one E(B:Bc) and flip AF */
02210       edgeData[e_id].num.in_AF++;
02211       edgeData[e_id].num.n_AtoAc--;
02212       edgeData[e_id].num.n_BtoBc--;
02213       break;
02214     case 3U:
02215       /* in this case we pay one E(A:Ac) and double flip BF, save 
02216        * one E(B:Bc) and flip AF */
02217       edgeData[e_id].num.in_AF++;
02218       edgeData[e_id].num.n_AtoAc++;
02219       edgeData[e_id].num.n_BtoBc--;
02220       break;
02221     case 5U:
02222       /* in this case we save one E(A:Ac) and double flip BF, pay 
02223        * one E(B:Bc) and flip AF */
02224       edgeData[e_id].num.in_AF++;
02225       edgeData[e_id].num.n_AtoAc--;
02226       edgeData[e_id].num.n_BtoBc++;
02227       break;
02228     case 7U:
02229       /* in this case we pay one E(A:Ac) and double flip BF, pay 
02230        * one E(B:Bc) and flip AF */
02231       edgeData[e_id].num.in_AF++;
02232       edgeData[e_id].num.n_AtoAc++;
02233       edgeData[e_id].num.n_BtoBc++;
02234       break;
02235     default:
02236       EXIT (1, "This should not happen, value %u", pos);
02237     }                           /* end switch */
02238   }                             /* end loop through all incident edges */
02239   return 0;
02240 }
02241 
02242 
02243 
02244 /* ========================================================================= */
02247 /* ========================================================================= */
02248 static int KPTmakeMoveAcABBcflipAHBH (const KPTMove_t * const cur_move,
02249                                       const unsigned int update_flags)
02250 {
02251   /* local variables */
02252   unsigned int e_id,
02253     no_id,
02254     pos,
02255     n_id = cur_move->n_id,
02256     dom = cur_move->dom;
02257   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02258 
02259   /* update flags if necesary */
02260   if (update_flags)
02261   {
02262     EGbitSet (nodeData[n_id].flipAc, dom);
02263     EGbitSet (nodeData[n_id].flipB, dom);
02264   }
02265   /* flip the handle and change the node */
02266   KPTmoveAcA (n_id, dom);
02267   KPTmoveBBc (n_id, dom);
02268   KPTmoveAH (n_id);
02269   KPTmoveBH (n_id);
02270 
02271   /* we have to compute every move */
02272   for (; e_it; e_it = e_it->next)
02273   {
02274     e_id = KPTgetEdgeId (e_it);
02275     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
02276     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02277       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02278       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02279     switch (pos)
02280     {
02281     case 0U:
02282       /* in this case, flip AF and flip BF */
02283       edgeData[e_id].num.in_AF++;
02284       edgeData[e_id].num.in_BF++;
02285       break;
02286     case 3U:
02287       /* in this case we save one E(A:Ac) and double flip AF, save 
02288        * one E(B:Bc) and double flip BF */
02289       edgeData[e_id].num.n_AtoAc--;
02290       edgeData[e_id].num.n_BtoBc--;
02291       break;
02292     case 1U:
02293       /* in this case we pay one E(A:Ac) and double flip AF, save 
02294        * one E(B:Bc) and double flip BF */
02295       edgeData[e_id].num.n_AtoAc++;
02296       edgeData[e_id].num.n_BtoBc--;
02297       break;
02298     case 7U:
02299       /* in this case we save one E(A:Ac) and double flip AF, pay 
02300        * one E(B:Bc) and double flip BF */
02301       edgeData[e_id].num.n_AtoAc--;
02302       edgeData[e_id].num.n_BtoBc++;
02303       break;
02304     case 5U:
02305       /* in this case we pay one E(A:Ac) and double flip AF, pay 
02306        * one E(B:Bc) and double flip BF */
02307       edgeData[e_id].num.n_AtoAc++;
02308       edgeData[e_id].num.n_BtoBc++;
02309       break;
02310     default:
02311       EXIT (1, "This should not happen, value %u", pos);
02312     }                           /* end switch */
02313   }                             /* end loop through all incident edges */
02314   return 0;
02315 }
02316 
02317 /* ========================================================================= */
02320 /* ========================================================================= */
02321 static int KPTmakeMoveAAcBcBflipAHBH (const KPTMove_t * const cur_move,
02322                                       const unsigned int update_flags)
02323 {
02324   /* local variables */
02325   unsigned int e_id,
02326     no_id,
02327     pos,
02328     n_id = cur_move->n_id,
02329     dom = cur_move->dom;
02330   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02331 
02332   /* update flags if necesary */
02333   if (update_flags)
02334   {
02335     EGbitSet (nodeData[n_id].flipA, dom);
02336     EGbitSet (nodeData[n_id].flipBc, dom);
02337   }
02338   /* flip the handle and change the node */
02339   KPTmoveAAc (n_id, dom);
02340   KPTmoveBcB (n_id, dom);
02341   KPTmoveAH (n_id);
02342   KPTmoveBH (n_id);
02343 
02344   /* we have to compute every move */
02345   for (; e_it; e_it = e_it->next)
02346   {
02347     e_id = KPTgetEdgeId (e_it);
02348     no_id = KPTgetOtherEndId (n_id, e_it);
02349     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02350       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02351       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02352     switch (pos)
02353     {
02354     case 0U:
02355       /* in this case, flip AF and flip BF */
02356       edgeData[e_id].num.in_AF++;
02357       edgeData[e_id].num.in_BF++;
02358       break;
02359     case 5U:
02360       /* in this case we save one E(A:Ac) and double flip AF, save 
02361        * one E(B:Bc) and double flip BF */
02362       edgeData[e_id].num.n_AtoAc--;
02363       edgeData[e_id].num.n_BtoBc--;
02364       break;
02365     case 7U:
02366       /* in this case we pay one E(A:Ac) and double flip AF, save 
02367        * one E(B:Bc) and double flip BF */
02368       edgeData[e_id].num.n_AtoAc++;
02369       edgeData[e_id].num.n_BtoBc--;
02370       break;
02371     case 1U:
02372       /* in this case we save one E(A:Ac) and double flip AF, pay 
02373        * one E(B:Bc) and double flip BF */
02374       edgeData[e_id].num.n_AtoAc--;
02375       edgeData[e_id].num.n_BtoBc++;
02376       break;
02377     case 3U:
02378       /* in this case we pay one E(A:Ac) and double flip AF, pay 
02379        * one E(B:Bc) and double flip BF */
02380       edgeData[e_id].num.n_AtoAc++;
02381       edgeData[e_id].num.n_BtoBc++;
02382       break;
02383     default:
02384       EXIT (1, "This should not happen, value %u", pos);
02385     }                           /* end switch */
02386   }                             /* end loop through all incident edges */
02387   return 0;
02388 }
02389 
02390 /* ========================================================================= */
02393 /* ========================================================================= */
02394 static int KPTmakeMoveAcABcBflipAHBH (const KPTMove_t * const cur_move,
02395                                       const unsigned int update_flags)
02396 {
02397   /* local variables */
02398   unsigned int e_id,
02399     no_id,
02400     pos,
02401     n_id = cur_move->n_id,
02402     dom = cur_move->dom;
02403   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02404 
02405   /* update flags if necesary */
02406   if (update_flags)
02407   {
02408     EGbitSet (nodeData[n_id].flipAc, dom);
02409     EGbitSet (nodeData[n_id].flipBc, dom);
02410   }
02411   /* flip the handle and change the node */
02412   KPTmoveAcA (n_id, dom);
02413   KPTmoveBcB (n_id, dom);
02414   KPTmoveAH (n_id);
02415   KPTmoveBH (n_id);
02416 
02417   /* we have to compute every move */
02418   for (; e_it; e_it = e_it->next)
02419   {
02420     e_id = KPTgetEdgeId (e_it);
02421     no_id = KPTgetOtherEndId (n_id, e_it);
02422     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02423       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02424       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02425     switch (pos)
02426     {
02427     case 0U:
02428       /* in this case, flip AF and flip BF */
02429       edgeData[e_id].num.in_AF++;
02430       edgeData[e_id].num.in_BF++;
02431       break;
02432     case 7U:
02433       /* in this case we save one E(A:Ac) and double flip AF, save 
02434        * one E(B:Bc) and double flip BF */
02435       edgeData[e_id].num.n_AtoAc--;
02436       edgeData[e_id].num.n_BtoBc--;
02437       break;
02438     case 5U:
02439       /* in this case we pay one E(A:Ac) and double flip AF, save 
02440        * one E(B:Bc) and double flip BF */
02441       edgeData[e_id].num.n_AtoAc++;
02442       edgeData[e_id].num.n_BtoBc--;
02443       break;
02444     case 3U:
02445       /* in this case we save one E(A:Ac) and double flip AF, pay 
02446        * one E(B:Bc) and double flip BF */
02447       edgeData[e_id].num.n_AtoAc--;
02448       edgeData[e_id].num.n_BtoBc++;
02449       break;
02450     case 1U:
02451       /* in this case we pay one E(A:Ac) and double flip AF, pay 
02452        * one E(B:Bc) and double flip BF */
02453       edgeData[e_id].num.n_AtoAc++;
02454       edgeData[e_id].num.n_BtoBc++;
02455       break;
02456     default:
02457       EXIT (1, "This should not happen, value %u", pos);
02458     }                           /* end switch */
02459   }                             /* end loop through all incident edges */
02460   return 0;
02461 }
02462 
02463 /* ========================================================================= */
02466 /* ========================================================================= */
02467 static int KPTmakeMoveAAcBBcflipAHBH (const KPTMove_t * const cur_move,
02468                                       const unsigned int update_flags)
02469 {
02470   /* local variables */
02471   unsigned int e_id,
02472     no_id,
02473     pos,
02474     n_id = cur_move->n_id,
02475     dom = cur_move->dom;
02476   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02477 
02478   /* update flags if necesary */
02479   if (update_flags)
02480   {
02481     EGbitSet (nodeData[n_id].flipA, dom);
02482     EGbitSet (nodeData[n_id].flipB, dom);
02483   }
02484   /* flip the handle and change the node */
02485   KPTmoveAAc (n_id, dom);
02486   KPTmoveBBc (n_id, dom);
02487   KPTmoveAH (n_id);
02488   KPTmoveBH (n_id);
02489 
02490   /* we have to compute every move */
02491   for (; e_it; e_it = e_it->next)
02492   {
02493     e_id = KPTgetEdgeId (e_it);
02494     no_id = KPTgetOtherEndId (n_id, e_it);
02495     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02496       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02497       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02498     switch (pos)
02499     {
02500     case 0U:
02501       /* in this case, flip AF and flip BF */
02502       edgeData[e_id].num.in_AF++;
02503       edgeData[e_id].num.in_BF++;
02504       break;
02505     case 1U:
02506       /* in this case we save one E(A:Ac) and double flip AF, save 
02507        * one E(B:Bc) and double flip BF */
02508       edgeData[e_id].num.n_AtoAc--;
02509       edgeData[e_id].num.n_BtoBc--;
02510       break;
02511     case 3U:
02512       /* in this case we pay one E(A:Ac) and double flip AF, save 
02513        * one E(B:Bc) and double flip BF */
02514       edgeData[e_id].num.n_AtoAc++;
02515       edgeData[e_id].num.n_BtoBc--;
02516       break;
02517     case 5U:
02518       /* in this case we save one E(A:Ac) and double flip AF, pay 
02519        * one E(B:Bc) and double flip BF */
02520       edgeData[e_id].num.n_AtoAc--;
02521       edgeData[e_id].num.n_BtoBc++;
02522       break;
02523     case 7U:
02524       /* in this case we pay one E(A:Ac) and double flip AF, pay 
02525        * one E(B:Bc) and double flip BF */
02526       edgeData[e_id].num.n_AtoAc++;
02527       edgeData[e_id].num.n_BtoBc++;
02528       break;
02529     default:
02530       EXIT (1, "This should not happen, value %u", pos);
02531     }                           /* end switch */
02532   }                             /* end loop through all incident edges */
02533   return 0;
02534 }
02535 
02536 
02537 /* ========================================================================= */
02539 /* ========================================================================= */
02540 static int KPTmakeMoveABTc (const KPTMove_t * const cur_move)
02541 {
02542   /* local variables */
02543   unsigned int e_id,
02544     no_id,
02545     pos,
02546     dom = cur_move->dom,
02547     n_id = cur_move->n_id;
02548   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02549 
02550   /* now move the nodes around */
02551   graphData.n_A[1][dom]--;
02552   graphData.n_B[1][dom]--;
02553   graphData.n_Tc[dom]++;
02554   EGbitUnset (nodeData[n_id].It, dom);
02555   EGbitUnset (nodeData[n_id].Ia, dom);
02556   EGbitUnset (nodeData[n_id].Ib, dom);
02557   nodeData[n_id].n_in_A--;
02558   nodeData[n_id].n_in_B--;
02559   nodeData[n_id].n_in_T--;
02560   graphData.n_AdB[1][dom]--;
02561   EGbitUnset (nodeData[n_id].Iadb, dom);
02562   /* we have to compute every move */
02563   for (; e_it; e_it = e_it->next)
02564   {
02565     e_id = KPTgetEdgeId (e_it);
02566     no_id = KPTgetOtherEndId (n_id, e_it);
02567     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02568       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02569       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02570     switch (pos)
02571     {
02572     case 7U:
02573       /* in this case, the only change is that we have to pay for this edge in
02574        * Delta(T) */
02575       edgeData[e_id].num.n_dT++;
02576       break;
02577     case 1U:
02578       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
02579        * one E(B:Bc) and flip BF */
02580       edgeData[e_id].num.n_dT++;
02581       edgeData[e_id].num.n_AtoAc--;
02582       edgeData[e_id].num.in_AF++;
02583       edgeData[e_id].num.n_BtoBc--;
02584       edgeData[e_id].num.in_BF++;
02585       break;
02586     case 3U:
02587       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
02588       edgeData[e_id].num.n_dT++;
02589       edgeData[e_id].num.n_BtoBc--;
02590       edgeData[e_id].num.in_BF++;
02591       break;
02592     case 5U:
02593       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
02594       edgeData[e_id].num.n_dT++;
02595       edgeData[e_id].num.n_AtoAc--;
02596       edgeData[e_id].num.in_AF++;
02597       break;
02598     case 0U:
02599       /* in this case we save one Delta(T) */
02600       edgeData[e_id].num.n_dT--;
02601       break;
02602     default:
02603       EXIT (1, "This should not happen, value %u", pos);
02604     }                           /* end switch */
02605   }                             /* end loop through all incident edges */
02606   return 0;
02607 }
02608 
02609 /* ========================================================================= */
02611 /* ========================================================================= */
02612 static int KPTmakeMoveTcAcBc (const KPTMove_t * const cur_move,
02613                               const unsigned int update_flags)
02614 {
02615   /* local variables */
02616   unsigned int e_id,
02617     no_id,
02618     pos,
02619     dom = cur_move->dom,
02620     n_id = cur_move->n_id;
02621   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02622 
02623   /* update flags if necesary */
02624   if (update_flags)
02625     EGbitSet (nodeData[n_id].added, dom);
02626   /* nbow move the nodes */
02627   graphData.n_A[0][dom]++;
02628   graphData.n_B[0][dom]++;
02629   graphData.n_Tc[dom]--;
02630   EGbitSet (nodeData[n_id].It, dom);
02631   nodeData[n_id].n_in_T++;
02632   graphData.n_AdB[1][dom]++;
02633   EGbitSet (nodeData[n_id].Iadb, dom);
02634   /* we have to compute every move */
02635   for (; e_it; e_it = e_it->next)
02636   {
02637     e_id = KPTgetEdgeId (e_it);
02638     no_id = KPTgetOtherEndId (n_id, e_it);
02639     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02640       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02641       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02642     switch (pos)
02643     {
02644     case 0U:
02645       /* in this case, the only change is that we have to pay for this edge in
02646        * Delta(T) */
02647       edgeData[e_id].num.n_dT++;
02648       break;
02649     case 7U:
02650       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
02651        * one E(B:Bc) and flip BF */
02652       edgeData[e_id].num.n_dT--;
02653       edgeData[e_id].num.n_AtoAc++;
02654       edgeData[e_id].num.in_AF++;
02655       edgeData[e_id].num.n_BtoBc++;
02656       edgeData[e_id].num.in_BF++;
02657       break;
02658     case 5U:
02659       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
02660       edgeData[e_id].num.n_dT--;
02661       edgeData[e_id].num.n_BtoBc++;
02662       edgeData[e_id].num.in_BF++;
02663       break;
02664     case 3U:
02665       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
02666       edgeData[e_id].num.n_dT--;
02667       edgeData[e_id].num.n_AtoAc++;
02668       edgeData[e_id].num.in_AF++;
02669       break;
02670     case 1U:
02671       /* in this case we save one Delta(T) */
02672       edgeData[e_id].num.n_dT--;
02673       break;
02674     default:
02675       EXIT (1, "This should not happen, value %u", pos);
02676     }                           /* end switch */
02677   }                             /* end loop through all incident edges */
02678   return 0;
02679 }
02680 
02681 /* ========================================================================= */
02683 /* ========================================================================= */
02684 static int KPTmakeMoveTcABc (const KPTMove_t * const cur_move,
02685                              const unsigned int update_flags)
02686 {
02687   /* local variables */
02688   unsigned int e_id,
02689     no_id,
02690     pos,
02691     dom = cur_move->dom,
02692     n_id = cur_move->n_id;
02693   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02694 
02695   /* update flags */
02696   if (update_flags)
02697     EGbitSet (nodeData[n_id].added, dom);
02698   /* move the node */
02699   graphData.n_A[1][dom]++;
02700   graphData.n_B[0][dom]++;
02701   graphData.n_Tc[dom]--;
02702   EGbitSet (nodeData[n_id].It, dom);
02703   EGbitSet (nodeData[n_id].Ia, dom);
02704   nodeData[n_id].n_in_A++;
02705   nodeData[n_id].n_in_T++;
02706   graphData.n_AdB[0][dom]++;
02707   EGbitUnset (nodeData[n_id].Iadb, dom);
02708   /* we have to compute every move */
02709   for (; e_it; e_it = e_it->next)
02710   {
02711     e_id = KPTgetEdgeId (e_it);
02712     no_id = KPTgetOtherEndId (n_id, e_it);
02713     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02714       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02715       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02716     switch (pos)
02717     {
02718     case 0U:
02719       /* in this case, the only change is that we have to pay for this edge in
02720        * Delta(T) */
02721       edgeData[e_id].num.n_dT++;
02722       break;
02723     case 5U:
02724       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
02725        * one E(B:Bc) and flip BF */
02726       edgeData[e_id].num.n_dT--;
02727       edgeData[e_id].num.n_AtoAc++;
02728       edgeData[e_id].num.in_AF++;
02729       edgeData[e_id].num.n_BtoBc++;
02730       edgeData[e_id].num.in_BF++;
02731       break;
02732     case 7U:
02733       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
02734       edgeData[e_id].num.n_dT--;
02735       edgeData[e_id].num.n_BtoBc++;
02736       edgeData[e_id].num.in_BF++;
02737       break;
02738     case 1U:
02739       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
02740       edgeData[e_id].num.n_dT--;
02741       edgeData[e_id].num.n_AtoAc++;
02742       edgeData[e_id].num.in_AF++;
02743       break;
02744     case 3U:
02745       /* in this case we save one Delta(T) */
02746       edgeData[e_id].num.n_dT--;
02747       break;
02748     default:
02749       EXIT (1, "This should not happen, value %u", pos);
02750     }                           /* end switch */
02751   }                             /* end loop through all incident edges */
02752   return 0;
02753 }
02754 
02755 /* ========================================================================= */
02757 /* ========================================================================= */
02758 static int KPTmakeMoveTcAcB (const KPTMove_t * const cur_move,
02759                              const unsigned int update_flags)
02760 {
02761   /* local variables */
02762   unsigned int e_id,
02763     no_id,
02764     pos,
02765     dom = cur_move->dom,
02766     n_id = cur_move->n_id;
02767   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02768 
02769   /* update flags if necesary */
02770   if (update_flags)
02771     EGbitSet (nodeData[n_id].added, dom);
02772   /* move the node */
02773   graphData.n_A[0][dom]++;
02774   graphData.n_B[1][dom]++;
02775   graphData.n_Tc[dom]--;
02776   EGbitSet (nodeData[n_id].It, dom);
02777   EGbitSet (nodeData[n_id].Ib, dom);
02778   nodeData[n_id].n_in_T++;
02779   nodeData[n_id].n_in_B++;
02780   graphData.n_AdB[0][dom]++;
02781   EGbitUnset (nodeData[n_id].Iadb, dom);
02782   /* we have to compute every move */
02783   for (; e_it; e_it = e_it->next)
02784   {
02785     e_id = KPTgetEdgeId (e_it);
02786     no_id = KPTgetOtherEndId (n_id, e_it);
02787     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02788       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02789       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02790     switch (pos)
02791     {
02792     case 0U:
02793       /* in this case, the only change is that we have to pay for this edge in
02794        * Delta(T) */
02795       edgeData[e_id].num.n_dT++;
02796       break;
02797     case 3U:
02798       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
02799        * one E(B:Bc) and flip BF */
02800       edgeData[e_id].num.n_dT--;
02801       edgeData[e_id].num.n_AtoAc++;
02802       edgeData[e_id].num.in_AF++;
02803       edgeData[e_id].num.n_BtoBc++;
02804       edgeData[e_id].num.in_BF++;
02805       break;
02806     case 1U:
02807       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
02808       edgeData[e_id].num.n_dT--;
02809       edgeData[e_id].num.n_BtoBc++;
02810       edgeData[e_id].num.in_BF++;
02811       break;
02812     case 7U:
02813       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
02814       edgeData[e_id].num.n_dT--;
02815       edgeData[e_id].num.n_AtoAc++;
02816       edgeData[e_id].num.in_AF++;
02817       break;
02818     case 5U:
02819       /* in this case we save one Delta(T) */
02820       edgeData[e_id].num.n_dT--;
02821       break;
02822     default:
02823       EXIT (1, "This should not happen, value %u", pos);
02824     }                           /* end switch */
02825   }                             /* end loop through all incident edges */
02826   return 0;
02827 }
02828 
02829 /* ========================================================================= */
02831 /* ========================================================================= */
02832 static int KPTmakeMoveTcAB (const KPTMove_t * const cur_move,
02833                             const unsigned int update_flags)
02834 {
02835   /* local variables */
02836   unsigned int e_id,
02837     no_id,
02838     pos,
02839     dom = cur_move->dom,
02840     n_id = cur_move->n_id;
02841   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02842 
02843   /* update flags if needed */
02844   if (update_flags)
02845     EGbitSet (nodeData[n_id].added, dom);
02846   /* move hte node */
02847   graphData.n_A[1][dom]++;
02848   graphData.n_B[1][dom]++;
02849   graphData.n_Tc[dom]--;
02850   EGbitSet (nodeData[n_id].It, dom);
02851   EGbitSet (nodeData[n_id].Ia, dom);
02852   EGbitSet (nodeData[n_id].Ib, dom);
02853   nodeData[n_id].n_in_T++;
02854   nodeData[n_id].n_in_A++;
02855   nodeData[n_id].n_in_B++;
02856   graphData.n_AdB[1][dom]++;
02857   EGbitSet (nodeData[n_id].Iadb, dom);
02858   /* we have to compute every move */
02859   for (; e_it; e_it = e_it->next)
02860   {
02861     e_id = KPTgetEdgeId (e_it);
02862     no_id = KPTgetOtherEndId (n_id, e_it);
02863     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
02864       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02865       (EGbitTest (nodeData[no_id].Ib, dom) ? 4U : 0U);
02866     switch (pos)
02867     {
02868     case 0U:
02869       /* in this case, the only change is that we have to pay for this edge in
02870        * Delta(T) */
02871       edgeData[e_id].num.n_dT++;
02872       break;
02873     case 1U:
02874       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
02875        * one E(B:Bc) and flip BF */
02876       edgeData[e_id].num.n_dT--;
02877       edgeData[e_id].num.n_AtoAc++;
02878       edgeData[e_id].num.in_AF++;
02879       edgeData[e_id].num.n_BtoBc++;
02880       edgeData[e_id].num.in_BF++;
02881       break;
02882     case 3U:
02883       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
02884       edgeData[e_id].num.n_dT--;
02885       edgeData[e_id].num.n_BtoBc++;
02886       edgeData[e_id].num.in_BF++;
02887       break;
02888     case 5U:
02889       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
02890       edgeData[e_id].num.n_dT--;
02891       edgeData[e_id].num.n_AtoAc++;
02892       edgeData[e_id].num.in_AF++;
02893       break;
02894     case 7U:
02895       /* in this case we save one Delta(T) */
02896       edgeData[e_id].num.n_dT--;
02897       break;
02898     default:
02899       EXIT (1, "This should not happen, value %u", pos);
02900     }                           /* end switch */
02901   }                             /* end loop through all incident edges */
02902   return 0;
02903 }
02904 
02905 /* ========================================================================= */
02907 /* ========================================================================= */
02908 static int KPTmakeMoveTcA (KPTMove_t const *const move,
02909                            const unsigned int update_flags)
02910 {
02911   /* local vaariables */
02912   unsigned int e_id,
02913     no_id,
02914     pos,
02915     dom = move->dom,
02916     n_id = move->n_id;
02917   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02918 
02919   /* we have to change all related edges */
02920   for (; e_it; e_it = e_it->next)
02921   {
02922     e_id = KPTgetEdgeId (e_it);
02923     no_id = KPTgetOtherEndId (n_id, e_it);
02924     pos = (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02925       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
02926     switch (pos)
02927     {
02928     case 0U:
02929       /* in this case the only change is that we have to pay for this edge in the
02930        * Delta(T) */
02931       edgeData[e_id].num.n_dT++;
02932       break;
02933       /* in this case we save one Delta(T), pay one E(A:B) and flip in_F because
02934        * we are changing parity of \sum E(A:B) */
02935     case 1U:
02936       edgeData[e_id].num.n_dT--;
02937       edgeData[e_id].num.n_AtoAc++;
02938       edgeData[e_id].num.in_AF++;
02939       break;
02940       /* in this case we save one Delta(T) */
02941     case 3U:
02942       edgeData[e_id].num.n_dT--;
02943       break;
02944     default:
02945       EXIT (1, "This should not happen");
02946     }                           /* end switch */
02947   }
02948 
02949   /* move the node */
02950   graphData.n_Tc[dom]--;
02951   graphData.n_A[1][dom]++;
02952   EGbitSet (nodeData[n_id].Ia, dom);
02953   EGbitSet (nodeData[n_id].It, dom);
02954   nodeData[n_id].n_in_A++;
02955   nodeData[n_id].n_in_T++;
02956   if (update_flags)
02957     EGbitSet (nodeData[n_id].added, dom);
02958   /* ending */
02959   return 0;
02960 }
02961 
02962 /* ========================================================================= */
02964 /* ========================================================================= */
02965 static int KPTmakeMoveTcAc (KPTMove_t const *const move,
02966                             const unsigned int update_flags)
02967 {
02968   /* local vaariables */
02969   unsigned int e_id,
02970     no_id,
02971     pos,
02972     dom = move->dom,
02973     n_id = move->n_id;
02974   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
02975 
02976   /* we have to change all related edges */
02977   for (; e_it; e_it = e_it->next)
02978   {
02979     e_id = KPTgetEdgeId (e_it);
02980     no_id = KPTgetOtherEndId (n_id, e_it);
02981     pos = (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
02982       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
02983     switch (pos)
02984     {
02985     case 0U:
02986       /* in this case the only change is that we have to pay for this edge in the
02987        * Delta(T) */
02988       edgeData[e_id].num.n_dT++;
02989       break;
02990       /* in this case we save one Delta(T), pay one E(A:Ac) and flip in_F because
02991        * we are changing parity of \sum E(A:B) */
02992     case 3U:
02993       edgeData[e_id].num.n_dT--;
02994       edgeData[e_id].num.n_AtoAc++;
02995       edgeData[e_id].num.in_AF++;
02996       break;
02997       /* in this case we save one Delta(T) */
02998     case 1U:
02999       edgeData[e_id].num.n_dT--;
03000       break;
03001     default:
03002       EXIT (1, "This should not happen");
03003     }                           /* end switch */
03004   }
03005 
03006   /* move the node */
03007   graphData.n_Tc[dom]--;
03008   graphData.n_A[0][dom]++;
03009   EGbitSet (nodeData[n_id].It, dom);
03010   nodeData[n_id].n_in_T++;
03011   if (update_flags)
03012     EGbitSet (nodeData[n_id].added, dom);
03013   /* ending */
03014   return 0;
03015 }
03016 
03017 /* ========================================================================= */
03019 /* ========================================================================= */
03020 static int KPTmakeMoveTcB (KPTMove_t const *const move,
03021                            const unsigned int update_flags)
03022 {
03023   /* local vaariables */
03024   unsigned int e_id,
03025     no_id,
03026     pos,
03027     dom = move->dom,
03028     n_id = move->n_id;
03029   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03030 
03031   /* move the node */
03032   graphData.n_Tc[dom]--;
03033   graphData.n_B[1][dom]++;
03034   EGbitSet (nodeData[n_id].Ib, dom);
03035   EGbitSet (nodeData[n_id].It, dom);
03036   nodeData[n_id].n_in_T++;
03037   nodeData[n_id].n_in_B++;
03038   if (update_flags)
03039     EGbitSet (nodeData[n_id].added, dom);
03040 
03041   /* we have to change all related edges */
03042   for (; e_it; e_it = e_it->next)
03043   {
03044     e_id = KPTgetEdgeId (e_it);
03045     no_id = KPTgetOtherEndId (n_id, e_it);
03046     pos = (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U) |
03047       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03048     switch (pos)
03049     {
03050     case 0U:
03051       /* in this case the only change is that we have to pay for this edge in the
03052        * Delta(T) */
03053       edgeData[e_id].num.n_dT++;
03054       break;
03055       /* in this case we save one Delta(T), pay one E(B:Bc) and flip in_F because
03056        * we are changing parity of \sum E(B:Bc) */
03057     case 1U:
03058       edgeData[e_id].num.n_dT--;
03059       edgeData[e_id].num.n_BtoBc++;
03060       edgeData[e_id].num.in_BF++;
03061       break;
03062       /* in this case we save one Delta(T) */
03063     case 3U:
03064       edgeData[e_id].num.n_dT--;
03065       break;
03066     default:
03067       EXIT (1, "This should not happen");
03068     }                           /* end switch */
03069   }
03070   return 0;
03071 }
03072 
03073 /* ========================================================================= */
03075 /* ========================================================================= */
03076 static int KPTmakeMoveTcBc (KPTMove_t const *const move,
03077                             const unsigned int update_flags)
03078 {
03079   /* local vaariables */
03080   unsigned int e_id,
03081     no_id,
03082     pos,
03083     dom = move->dom,
03084     n_id = move->n_id;
03085   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03086 
03087   /* move the node */
03088   graphData.n_Tc[dom]--;
03089   graphData.n_B[0][dom]++;
03090   EGbitSet (nodeData[n_id].It, dom);
03091   nodeData[n_id].n_in_T++;
03092   if (update_flags)
03093     EGbitSet (nodeData[n_id].added, dom);
03094 
03095   /* we have to change all related edges */
03096   for (; e_it; e_it = e_it->next)
03097   {
03098     e_id = KPTgetEdgeId (e_it);
03099     no_id = KPTgetOtherEndId (n_id, e_it);
03100     pos = (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U) |
03101       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03102     switch (pos)
03103     {
03104     case 0U:
03105       /* in this case the only change is that we have to pay for this edge in the
03106        * Delta(T) */
03107       edgeData[e_id].num.n_dT++;
03108       break;
03109       /* in this case we save one Delta(T), pay one E(B:Bc) and flip in_F because
03110        * we are changing parity of \sum E(B:Bc) */
03111     case 3U:
03112       edgeData[e_id].num.n_dT--;
03113       edgeData[e_id].num.n_BtoBc++;
03114       edgeData[e_id].num.in_BF++;
03115       break;
03116       /* in this case we save one Delta(T) */
03117     case 1U:
03118       edgeData[e_id].num.n_dT--;
03119       break;
03120     default:
03121       EXIT (1, "This should not happen");
03122     }                           /* end switch */
03123   }
03124   return 0;
03125 }
03126 
03127 /* ========================================================================= */
03129 /* ========================================================================= */
03130 static int KPTmakeMoveATc (KPTMove_t const *const move)
03131 {
03132   /* local vaariables */
03133   unsigned int e_id,
03134     no_id,
03135     pos,
03136     dom = move->dom,
03137     n_id = move->n_id;
03138   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03139 
03140   /* we have to change all related edges */
03141   for (; e_it; e_it = e_it->next)
03142   {
03143     e_id = KPTgetEdgeId (e_it);
03144     no_id = KPTgetOtherEndId (n_id, e_it);
03145     pos = (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
03146       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03147     switch (pos)
03148     {
03149     case 0U:
03150       /* in this case the only change is that we have to save forthis edge in the
03151        * Delta(T) */
03152       edgeData[e_id].num.n_dT--;
03153       break;
03154       /* in this case we pay one Delta(T), save one E(A:Ac) flip in_AF because
03155        * we are changing parity of \sum E(A:Ac) */
03156     case 1U:
03157       edgeData[e_id].num.n_dT++;
03158       edgeData[e_id].num.n_AtoAc--;
03159       edgeData[e_id].num.in_AF++;
03160       break;
03161       /* in this case we pay one Delta(T) */
03162     case 3U:
03163       edgeData[e_id].num.n_dT++;
03164       break;
03165     default:
03166       EXIT (1, "This should not happen");
03167     }                           /* end switch */
03168   }
03169 
03170   /* move the node */
03171   graphData.n_Tc[dom]++;
03172   graphData.n_A[1][dom]--;
03173   EGbitUnset (nodeData[n_id].Ia, dom);
03174   EGbitUnset (nodeData[n_id].It, dom);
03175   nodeData[n_id].n_in_A--;
03176   nodeData[n_id].n_in_T--;
03177   /* ending */
03178   return 0;
03179 }
03180 
03181 /* ========================================================================= */
03183 /* ========================================================================= */
03184 static int KPTmakeMoveAcTc (KPTMove_t const *const move)
03185 {
03186   /* local vaariables */
03187   unsigned int e_id,
03188     no_id,
03189     pos,
03190     dom = move->dom,
03191     n_id = move->n_id;
03192   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03193 
03194   /* we have to change all related edges */
03195   for (; e_it; e_it = e_it->next)
03196   {
03197     e_id = KPTgetEdgeId (e_it);
03198     no_id = KPTgetOtherEndId (n_id, e_it);
03199     pos = (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U) |
03200       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03201     switch (pos)
03202     {
03203     case 0U:
03204       /* in this case the only change is that we have to save this edge in the
03205        * Delta(T) */
03206       edgeData[e_id].num.n_dT--;
03207       break;
03208       /* in this case we pay one Delta(T), save one E(A:Ac) flip in_F because
03209        * we are changing parity of \sum E(A:B) */
03210     case 3U:
03211       edgeData[e_id].num.n_dT++;
03212       edgeData[e_id].num.n_AtoAc--;
03213       edgeData[e_id].num.in_AF++;
03214       break;
03215       /* in this case we paye one Delta(T) */
03216     case 1U:
03217       edgeData[e_id].num.n_dT++;
03218       break;
03219     default:
03220       EXIT (1, "This should not happen");
03221     }                           /* end switch */
03222   }
03223 
03224   /* move the node */
03225   graphData.n_Tc[dom]++;
03226   graphData.n_A[0][dom]--;
03227   EGbitUnset (nodeData[n_id].It, dom);
03228   nodeData[n_id].n_in_T--;
03229   /* ending */
03230   return 0;
03231 }
03232 
03233 /* ========================================================================= */
03235 /* ========================================================================= */
03236 static int KPTmakeMoveBTc (KPTMove_t const *const move)
03237 {
03238   /* local vaariables */
03239   unsigned int e_id,
03240     no_id,
03241     pos,
03242     dom = move->dom,
03243     n_id = move->n_id;
03244   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03245 
03246   /* move the node */
03247   graphData.n_Tc[dom]++;
03248   graphData.n_B[1][dom]--;
03249   EGbitUnset (nodeData[n_id].Ib, dom);
03250   EGbitUnset (nodeData[n_id].It, dom);
03251   nodeData[n_id].n_in_T--;
03252   nodeData[n_id].n_in_B--;
03253 
03254   /* we have to change all related edges */
03255   for (; e_it; e_it = e_it->next)
03256   {
03257     e_id = KPTgetEdgeId (e_it);
03258     no_id = KPTgetOtherEndId (n_id, e_it);
03259     pos = (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U) |
03260       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03261     switch (pos)
03262     {
03263     case 0U:
03264       /* in this case the only change is that we save for this edge in the
03265        * Delta(T) */
03266       edgeData[e_id].num.n_dT--;
03267       break;
03268       /* in this case we pay one Delta(T), save one E(B:Bc) and flip in_F because
03269        * we are changing parity of \sum E(B:Bc) */
03270     case 1U:
03271       edgeData[e_id].num.n_dT++;
03272       edgeData[e_id].num.n_BtoBc--;
03273       edgeData[e_id].num.in_BF++;
03274       break;
03275       /* in this case we pay one Delta(T) */
03276     case 3U:
03277       edgeData[e_id].num.n_dT++;
03278       break;
03279     default:
03280       EXIT (1, "This should not happen");
03281     }                           /* end switch */
03282   }
03283   return 0;
03284 }
03285 
03286 /* ========================================================================= */
03288 /* ========================================================================= */
03289 static int KPTmakeMoveBcTc (KPTMove_t const *const move)
03290 {
03291   /* local vaariables */
03292   unsigned int e_id,
03293     no_id,
03294     pos,
03295     dom = move->dom,
03296     n_id = move->n_id;
03297   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
03298 
03299   /* move the node */
03300   graphData.n_Tc[dom]++;
03301   graphData.n_B[0][dom]--;
03302   EGbitUnset (nodeData[n_id].It, dom);
03303   nodeData[n_id].n_in_T--;
03304 
03305   /* we have to change all related edges */
03306   for (; e_it; e_it = e_it->next)
03307   {
03308     e_id = KPTgetEdgeId (e_it);
03309     no_id = KPTgetOtherEndId (n_id, e_it);
03310     pos = (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U) |
03311       (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U);
03312     switch (pos)
03313     {
03314     case 0U:
03315       /* in this case the only change is that we save for this edge in the
03316        * Delta(T) */
03317       edgeData[e_id].num.n_dT--;
03318       break;
03319       /* in this case we pay one Delta(T), save one E(B:Bc) and flip in_F because
03320        * we are changing parity of \sum E(B:Bc) */
03321     case 3U:
03322       edgeData[e_id].num.n_dT++;
03323       edgeData[e_id].num.n_BtoBc--;
03324       edgeData[e_id].num.in_BF++;
03325       break;
03326       /* in this case we pay one Delta(T) */
03327     case 1U:
03328       edgeData[e_id].num.n_dT++;
03329       break;
03330     default:
03331       EXIT (1, "This should not happen");
03332     }                           /* end switch */
03333   }
03334   return 0;
03335 }
03336 
03337 /* ========================================================================= */
03340 /* ========================================================================= */
03341 static int KPTTestEdges (void)
03342 {
03343   /* local variables */
03344   register unsigned int i = G->nedges,
03345     j;
03346   unsigned int n_AtoAc,
03347     n_dT,
03348     N1_id,
03349     N2_id,
03350     N1_inA,
03351     N1_inB,
03352     N1_inTc,
03353     N2_inA,
03354     N2_inB,
03355     N2_inTc,
03356     in_AF,
03357     n_BtoBc,
03358     in_BF,
03359     pos;
03360   while (i--)
03361   {
03362     N1_id = all_edges[i]->head->id;
03363     N2_id = all_edges[i]->tail->id;
03364     n_AtoAc = n_BtoBc = n_dT = in_AF = in_BF = 0;
03365     for (j = graphData.n_dominos; j--;)
03366     {
03367       N1_inA = EGbitTest (nodeData[N1_id].Ia, j) ? 1U : 0U;
03368       N1_inB = EGbitTest (nodeData[N1_id].Ib, j) ? 1U : 0U;
03369       N1_inTc = EGbitTest (nodeData[N1_id].It, j) ? 0U : 1U;
03370       N2_inA = EGbitTest (nodeData[N2_id].Ia, j) ? 1U : 0U;
03371       N2_inB = EGbitTest (nodeData[N2_id].Ib, j) ? 1U : 0U;
03372       N2_inTc = EGbitTest (nodeData[N2_id].It, j) ? 0U : 1U;
03373       if ((!N1_inTc && N2_inTc) || (N1_inTc && !N2_inTc))
03374         n_dT++;
03375       if (!N1_inTc && !N2_inTc && (N1_inA != N2_inA))
03376         n_AtoAc++;
03377       if (!N1_inTc && !N2_inTc && (N1_inB != N2_inB))
03378         n_BtoBc++;
03379     }
03380     pos = 1U & ((nodeData[N1_id].in_AH ^ nodeData[N2_id].in_AH)
03381                 ^ edgeData[i].num.n_AtoAc);
03382     if (pos)
03383       in_AF = 1U;
03384     pos = 1U & ((nodeData[N1_id].in_BH ^ nodeData[N2_id].in_BH)
03385                 ^ edgeData[i].num.n_BtoBc);
03386     if (pos)
03387       in_BF = 1U;
03388     TEST (in_BF != edgeData[i].num.in_BF || in_AF != edgeData[i].num.in_AF ||
03389           n_dT != edgeData[i].num.n_dT || n_AtoAc != edgeData[i].num.n_AtoAc ||
03390           n_BtoBc != edgeData[i].num.n_BtoBc, "in_AF(%u,%u) in_BF(%u,%u)"
03391           " n_dT(%u,%u) n_AtoAc(%u,%u) n_BtoBc(%u,%u) don't match for edge %u",
03392           in_AF, edgeData[i].num.in_AF, in_BF, edgeData[i].num.in_BF, n_dT,
03393           edgeData[i].num.n_dT, n_AtoAc, edgeData[i].num.n_AtoAc, n_BtoBc,
03394           edgeData[i].num.n_BtoBc, i);
03395   }
03396   return 0;
03397 }
03398 
03399 /* ========================================================================= */
03401 /* ========================================================================= */
03402 #define KPTmakeMove(__move,__flags) __KPTmakeMove(__move,__flags,__LINE__,__FILE__,__func__)
03403 static int __KPTmakeMove (KPTMove_t const *const move,
03404                           const unsigned int update_flags,
03405                           const int line,
03406                           const char *file,
03407                           const char *function)
03408 {
03409   /* we just switch the correct call */
03410   MESSAGE (KPT_VRB + 19, "doing move %s for node %u from %s at %s:%d",
03411            move_name[move->move_id], move->n_id, function, file, line);
03412   switch (move->move_id)
03413   {
03414   case KPT_AB_Tc:
03415     KPTmakeMoveABTc (move);
03416     break;
03417   case KPT_AcB_Tc:
03418     KPTmakeMoveAcBTc (move);
03419     break;
03420   case KPT_ABc_Tc:
03421     KPTmakeMoveABcTc (move);
03422     break;
03423   case KPT_AcBc_Tc:
03424     KPTmakeMoveAcBcTc (move);
03425     break;
03426   case KPT_Tc_AB:
03427     KPTmakeMoveTcAB (move, update_flags);
03428     break;
03429   case KPT_Tc_AcB:
03430     KPTmakeMoveTcAcB (move, update_flags);
03431     break;
03432   case KPT_Tc_ABc:
03433     KPTmakeMoveTcABc (move, update_flags);
03434     break;
03435   case KPT_Tc_AcBc:
03436     KPTmakeMoveTcAcBc (move, update_flags);
03437     break;
03438   case KPT_Ac_A:
03439     KPTmakeMoveAcA (move, update_flags);
03440     break;
03441   case KPT_A_Ac:
03442     KPTmakeMoveAAc (move, update_flags);
03443     break;
03444   case KPT_Bc_B:
03445     KPTmakeMoveBcB (move, update_flags);
03446     break;
03447   case KPT_B_Bc:
03448     KPTmakeMoveBBc (move, update_flags);
03449     break;
03450   case KPT_Ac_A_B_Bc:
03451     KPTmakeMoveAcABBc (move, update_flags);
03452     break;
03453   case KPT_Ac_A_Bc_B:
03454     KPTmakeMoveAcABcB (move, update_flags);
03455     break;
03456   case KPT_A_Ac_B_Bc:
03457     KPTmakeMoveAAcBBc (move, update_flags);
03458     break;
03459   case KPT_A_Ac_Bc_B:
03460     KPTmakeMoveAAcBcB (move, update_flags);
03461     break;
03462   case KPT_Ac_A_B_Bc_flipAH:
03463     KPTmakeMoveAcABBcflipAH (move, update_flags);
03464     break;
03465   case KPT_Ac_A_Bc_B_flipAH:
03466     KPTmakeMoveAcABcBflipAH (move, update_flags);
03467     break;
03468   case KPT_A_Ac_B_Bc_flipAH:
03469     KPTmakeMoveAAcBBcflipAH (move, update_flags);
03470     break;
03471   case KPT_A_Ac_Bc_B_flipAH:
03472     KPTmakeMoveAAcBcBflipAH (move, update_flags);
03473     break;
03474   case KPT_Ac_A_B_Bc_flipBH:
03475     KPTmakeMoveAcABBcflipBH (move, update_flags);
03476     break;
03477   case KPT_Ac_A_Bc_B_flipBH:
03478     KPTmakeMoveAcABcBflipBH (move, update_flags);
03479     break;
03480   case KPT_A_Ac_B_Bc_flipBH:
03481     KPTmakeMoveAAcBBcflipBH (move, update_flags);
03482     break;
03483   case KPT_A_Ac_Bc_B_flipBH:
03484     KPTmakeMoveAAcBcBflipBH (move, update_flags);
03485     break;
03486   case KPT_Ac_A_B_Bc_flipAHBH:
03487     KPTmakeMoveAcABBcflipAHBH (move, update_flags);
03488     break;
03489   case KPT_Ac_A_Bc_B_flipAHBH:
03490     KPTmakeMoveAcABcBflipAHBH (move, update_flags);
03491     break;
03492   case KPT_A_Ac_B_Bc_flipAHBH:
03493     KPTmakeMoveAAcBBcflipAHBH (move, update_flags);
03494     break;
03495   case KPT_A_Ac_Bc_B_flipAHBH:
03496     KPTmakeMoveAAcBcBflipAHBH (move, update_flags);
03497     break;
03498   case KPT_Ac_A_flipAH:
03499     KPTmakeMoveAcAflipAH (move, update_flags);
03500     break;
03501   case KPT_A_Ac_flipAH:
03502     KPTmakeMoveAAcflipAH (move, update_flags);
03503     break;
03504   case KPT_Bc_B_flipBH:
03505     KPTmakeMoveBcBflipBH (move, update_flags);
03506     break;
03507   case KPT_B_Bc_flipBH:
03508     KPTmakeMoveBBcflipBH (move, update_flags);
03509     break;
03510   case KPT_A_Tc:
03511     KPTmakeMoveATc (move);
03512     break;
03513   case KPT_B_Tc:
03514     KPTmakeMoveBTc (move);
03515     break;
03516   case KPT_Ac_Tc:
03517     KPTmakeMoveAcTc (move);
03518     break;
03519   case KPT_Bc_Tc:
03520     KPTmakeMoveBcTc (move);
03521     break;
03522   case KPT_Tc_A:
03523     KPTmakeMoveTcA (move, update_flags);
03524     break;
03525   case KPT_Tc_B:
03526     KPTmakeMoveTcB (move, update_flags);
03527     break;
03528   case KPT_Tc_Ac:
03529     KPTmakeMoveTcAc (move, update_flags);
03530     break;
03531   case KPT_Tc_Bc:
03532     KPTmakeMoveTcBc (move, update_flags);
03533     break;
03534   case KPT_AHc_AH:
03535     KPTmakeMoveAHcAH (move, update_flags);
03536     break;
03537   case KPT_BHc_BH:
03538     KPTmakeMoveBHcBH (move, update_flags);
03539     break;
03540   case KPT_AH_AHc:
03541     KPTmakeMoveAHAHc (move, update_flags);
03542     break;
03543   case KPT_BH_BHc:
03544     KPTmakeMoveBHBHc (move, update_flags);
03545     break;
03546   case KPT_AH_AHc_BH_BHc:
03547     KPTmakeMoveAHAHcBHBHc (move, update_flags);
03548     break;
03549   case KPT_AH_AHc_BHc_BH:
03550     KPTmakeMoveAHAHcBHcBH (move, update_flags);
03551     break;
03552   case KPT_AHc_AH_BHc_BH:
03553     KPTmakeMoveAHcAHBHcBH (move, update_flags);
03554     break;
03555   case KPT_AHc_AH_BH_BHc:
03556     KPTmakeMoveAHcAHBHBHc (move, update_flags);
03557     break;
03558   default:
03559     EXIT (1, "unknown move %d", move->move_id);
03560   }
03561   /* ending */
03562 #if KPT_EDBG <= DEBUG
03563   EXIT (KPTTestEdges (), "after move %s", move_name[move->move_id]);
03564 #endif
03565   return 0;
03566 }
03567 
03568 /* ========================================================================= */
03570 /* ========================================================================= */
03571 static int KPTmakeInvMove (KPTMove_t const *const move,
03572                            const unsigned int update_flags)
03573 {
03574   /* we just switch the correct call */
03575   MESSAGE (KPT_VRB + 19, "doing inv move %s for node %u",
03576            move_name[move->move_id], move->n_id);
03577   switch (KPT_inv_move[move->move_id])
03578   {
03579   case KPT_AB_Tc:
03580     KPTmakeMoveABTc (move);
03581     break;
03582   case KPT_AcB_Tc:
03583     KPTmakeMoveAcBTc (move);
03584     break;
03585   case KPT_ABc_Tc:
03586     KPTmakeMoveABcTc (move);
03587     break;
03588   case KPT_AcBc_Tc:
03589     KPTmakeMoveAcBcTc (move);
03590     break;
03591   case KPT_Tc_AB:
03592     KPTmakeMoveTcAB (move, update_flags);
03593     break;
03594   case KPT_Tc_AcB:
03595     KPTmakeMoveTcAcB (move, update_flags);
03596     break;
03597   case KPT_Tc_ABc:
03598     KPTmakeMoveTcABc (move, update_flags);
03599     break;
03600   case KPT_Tc_AcBc:
03601     KPTmakeMoveTcAcBc (move, update_flags);
03602     break;
03603   case KPT_Ac_A:
03604     KPTmakeMoveAcA (move, update_flags);
03605     break;
03606   case KPT_A_Ac:
03607     KPTmakeMoveAAc (move, update_flags);
03608     break;
03609   case KPT_Bc_B:
03610     KPTmakeMoveBcB (move, update_flags);
03611     break;
03612   case KPT_B_Bc:
03613     KPTmakeMoveBBc (move, update_flags);
03614     break;
03615   case KPT_Ac_A_B_Bc:
03616     KPTmakeMoveAcABBc (move, update_flags);
03617     break;
03618   case KPT_Ac_A_Bc_B:
03619     KPTmakeMoveAcABcB (move, update_flags);
03620     break;
03621   case KPT_A_Ac_B_Bc:
03622     KPTmakeMoveAAcBBc (move, update_flags);
03623     break;
03624   case KPT_A_Ac_Bc_B:
03625     KPTmakeMoveAAcBcB (move, update_flags);
03626     break;
03627   case KPT_Ac_A_B_Bc_flipAH:
03628     KPTmakeMoveAcABBcflipAH (move, update_flags);
03629     break;
03630   case KPT_Ac_A_Bc_B_flipAH:
03631     KPTmakeMoveAcABcBflipAH (move, update_flags);
03632     break;
03633   case KPT_A_Ac_B_Bc_flipAH:
03634     KPTmakeMoveAAcBBcflipAH (move, update_flags);
03635     break;
03636   case KPT_A_Ac_Bc_B_flipAH:
03637     KPTmakeMoveAAcBcBflipAH (move, update_flags);
03638     break;
03639   case KPT_Ac_A_B_Bc_flipBH:
03640     KPTmakeMoveAcABBcflipBH (move, update_flags);
03641     break;
03642   case KPT_Ac_A_Bc_B_flipBH:
03643     KPTmakeMoveAcABcBflipBH (move, update_flags);
03644     break;
03645   case KPT_A_Ac_B_Bc_flipBH:
03646     KPTmakeMoveAAcBBcflipBH (move, update_flags);
03647     break;
03648   case KPT_A_Ac_Bc_B_flipBH:
03649     KPTmakeMoveAAcBcBflipBH (move, update_flags);
03650     break;
03651   case KPT_Ac_A_B_Bc_flipAHBH:
03652     KPTmakeMoveAcABBcflipAHBH (move, update_flags);
03653     break;
03654   case KPT_Ac_A_Bc_B_flipAHBH:
03655     KPTmakeMoveAcABcBflipAHBH (move, update_flags);
03656     break;
03657   case KPT_A_Ac_B_Bc_flipAHBH:
03658     KPTmakeMoveAAcBBcflipAHBH (move, update_flags);
03659     break;
03660   case KPT_A_Ac_Bc_B_flipAHBH:
03661     KPTmakeMoveAAcBcBflipAHBH (move, update_flags);
03662     break;
03663   case KPT_Ac_A_flipAH:
03664     KPTmakeMoveAcAflipAH (move, update_flags);
03665     break;
03666   case KPT_A_Ac_flipAH:
03667     KPTmakeMoveAAcflipAH (move, update_flags);
03668     break;
03669   case KPT_Bc_B_flipBH:
03670     KPTmakeMoveBcBflipBH (move, update_flags);
03671     break;
03672   case KPT_B_Bc_flipBH:
03673     KPTmakeMoveBBcflipBH (move, update_flags);
03674     break;
03675   case KPT_A_Tc:
03676     KPTmakeMoveATc (move);
03677     break;
03678   case KPT_B_Tc:
03679     KPTmakeMoveBTc (move);
03680     break;
03681   case KPT_Ac_Tc:
03682     KPTmakeMoveAcTc (move);
03683     break;
03684   case KPT_Bc_Tc:
03685     KPTmakeMoveBcTc (move);
03686     break;
03687   case KPT_Tc_A:
03688     KPTmakeMoveTcA (move, update_flags);
03689     break;
03690   case KPT_Tc_B:
03691     KPTmakeMoveTcB (move, update_flags);
03692     break;
03693   case KPT_Tc_Ac:
03694     KPTmakeMoveTcAc (move, update_flags);
03695     break;
03696   case KPT_Tc_Bc:
03697     KPTmakeMoveTcBc (move, update_flags);
03698     break;
03699   case KPT_AHc_AH:
03700     KPTmakeMoveAHcAH (move, update_flags);
03701     break;
03702   case KPT_BHc_BH:
03703     KPTmakeMoveBHcBH (move, update_flags);
03704     break;
03705   case KPT_AH_AHc:
03706     KPTmakeMoveAHAHc (move, update_flags);
03707     break;
03708   case KPT_BH_BHc:
03709     KPTmakeMoveBHBHc (move, update_flags);
03710     break;
03711   case KPT_AH_AHc_BH_BHc:
03712     KPTmakeMoveAHAHcBHBHc (move, update_flags);
03713     break;
03714   case KPT_AH_AHc_BHc_BH:
03715     KPTmakeMoveAHAHcBHcBH (move, update_flags);
03716     break;
03717   case KPT_AHc_AH_BHc_BH:
03718     KPTmakeMoveAHcAHBHcBH (move, update_flags);
03719     break;
03720   case KPT_AHc_AH_BH_BHc:
03721     KPTmakeMoveAHcAHBHBHc (move, update_flags);
03722     break;
03723   default:
03724     EXIT (1, "unknown move %d", move->move_id);
03725   }
03726   /* ending */
03727 #if KPT_EDBG <= DEBUG
03728   EXITRVAL (KPTTestEdges ());
03729 #endif
03730   return 0;
03731 }
03732 
03733 /* ========================================================================= */
03736 /* ========================================================================= */
03737 static int KPTisMoveFeasible (KPTMove_t const *const move,
03738                               const unsigned int update_flags)
03739 {
03740   int rval = 0;
03741   unsigned int type;
03742 
03743   MESSAGE (KPT_VRB, "Entering for node %u, move %s, domino %u",
03744            move->n_id, move_name[move->move_id], move->dom);
03745 
03746   /* we just switch the correct call */
03747   switch (move->move_id)
03748   {
03749   case KPT_Tc_Ac:
03750   case KPT_Tc_A:
03751     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
03752       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
03753     rval = !EGbitTest (nodeData[move->n_id].It, move->dom) &&
03754       (graphData.n_Tc[move->dom] > 1) && (!update_flags ||
03755                                           !EGbitTest (nodeData[move->n_id].
03756                                                       added, move->dom))
03757       && (type == 1U);
03758     break;
03759   case KPT_Tc_Bc:
03760   case KPT_Tc_B:
03761     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
03762       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
03763     rval = !EGbitTest (nodeData[move->n_id].It, move->dom) &&
03764       (graphData.n_Tc[move->dom] > 1) && (!update_flags ||
03765                                           !EGbitTest (nodeData[move->n_id].
03766                                                       added, move->dom))
03767       && (type == 2U);
03768     break;
03769   case KPT_Tc_AB:
03770   case KPT_Tc_ABc:
03771   case KPT_Tc_AcBc:
03772   case KPT_Tc_AcB:
03773     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
03774       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
03775     rval = !EGbitTest (nodeData[move->n_id].It, move->dom) &&
03776       (graphData.n_Tc[move->dom] > 1) && (!update_flags ||
03777                                           !EGbitTest (nodeData[move->n_id].
03778                                                       added, move->dom))
03779       && (type == 3U);
03780     break;
03781   case KPT_AHc_AH:
03782     rval = !nodeData[move->n_id].in_AH && (graphData.n_AH[0] > 1) &&
03783       (!update_flags || !nodeData[move->n_id].added_AH);
03784     break;
03785   case KPT_BHc_BH:
03786     rval = !nodeData[move->n_id].in_BH && (graphData.n_BH[0] > 1) &&
03787       (!update_flags || !nodeData[move->n_id].added_BH);
03788     break;
03789   case KPT_AHc_AH_BHc_BH:
03790     rval = !nodeData[move->n_id].in_BH && (graphData.n_BH[0] > 1) &&
03791       (!update_flags || (!nodeData[move->n_id].added_BH &&
03792                          !nodeData[move->n_id].added_AH)) &&
03793       !nodeData[move->n_id].in_AH && (graphData.n_AH[0] > 1);
03794     break;
03795   case KPT_A_Ac:
03796     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03797       (graphData.n_A[1][move->dom] > 1) && (!update_flags ||
03798                                             !EGbitTest (nodeData[move->n_id].
03799                                                         flipA, move->dom))
03800       && (!EGbitTest (graphData.Kdom, move->dom)
03801           || (graphData.
03802               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03803                     0U][move->dom] > 1));
03804     break;
03805   case KPT_A_Ac_flipAH:
03806     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03807       (graphData.n_A[1][move->dom] > 1) && (!update_flags ||
03808                                             (!EGbitTest
03809                                              (nodeData[move->n_id].flipA,
03810                                               move->dom)))
03811       && (graphData.n_AH[nodeData[move->n_id].in_AH] > 1)
03812       && (!EGbitTest (graphData.Kdom, move->dom)
03813           || (graphData.
03814               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03815                     0U][move->dom] > 1));
03816     break;
03817   case KPT_Ac_A:
03818     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03819       (graphData.n_A[0][move->dom] > 1) && (!update_flags ||
03820                                             !EGbitTest (nodeData[move->n_id].
03821                                                         flipAc, move->dom))
03822       && EGbitTest (nodeData[move->n_id].It, move->dom)
03823       && (!EGbitTest (graphData.Kdom, move->dom)
03824           || (graphData.
03825               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03826                     0U][move->dom] > 1));
03827     break;
03828   case KPT_Ac_A_flipAH:
03829     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03830       (graphData.n_A[0][move->dom] > 1) && (!update_flags ||
03831                                             (!EGbitTest
03832                                              (nodeData[move->n_id].flipAc,
03833                                               move->dom)))
03834       && (graphData.n_AH[nodeData[move->n_id].in_AH] > 1)
03835       && EGbitTest (nodeData[move->n_id].It, move->dom)
03836       && (!EGbitTest (graphData.Kdom, move->dom)
03837           || (graphData.
03838               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03839                     0U][move->dom] > 1));
03840     break;
03841   case KPT_B_Bc:
03842     rval = EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03843       (graphData.n_B[1][move->dom] > 1) && (!update_flags ||
03844                                             !EGbitTest (nodeData[move->n_id].
03845                                                         flipB, move->dom))
03846       && (!EGbitTest (graphData.Kdom, move->dom)
03847           || (graphData.
03848               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03849                     0U][move->dom] > 1));
03850     break;
03851   case KPT_B_Bc_flipBH:
03852     rval = EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03853       (graphData.n_B[1][move->dom] > 1) && (!update_flags ||
03854                                             (!EGbitTest
03855                                              (nodeData[move->n_id].flipB,
03856                                               move->dom)))
03857       && (graphData.n_BH[nodeData[move->n_id].in_BH] > 1)
03858       && (!EGbitTest (graphData.Kdom, move->dom)
03859           || (graphData.
03860               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03861                     0U][move->dom] > 1));
03862     break;
03863   case KPT_Bc_B:
03864     rval = !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03865       (graphData.n_B[0][move->dom] > 1) && (!update_flags ||
03866                                             !EGbitTest (nodeData[move->n_id].
03867                                                         flipBc, move->dom))
03868       && EGbitTest (nodeData[move->n_id].It, move->dom)
03869       && (!EGbitTest (graphData.Kdom, move->dom)
03870           || (graphData.
03871               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03872                     0U][move->dom] > 1));
03873     break;
03874   case KPT_Bc_B_flipBH:
03875     rval = !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03876       (graphData.n_B[0][move->dom] > 1) && (!update_flags ||
03877                                             (!EGbitTest
03878                                              (nodeData[move->n_id].flipBc,
03879                                               move->dom)))
03880       && (graphData.n_BH[nodeData[move->n_id].in_BH] > 1)
03881       && EGbitTest (nodeData[move->n_id].It, move->dom)
03882       && (!EGbitTest (graphData.Kdom, move->dom)
03883           || (graphData.
03884               n_AdB[EGbitTest (nodeData[move->n_id].Iadb, move->dom) ? 1U :
03885                     0U][move->dom] > 1));
03886     break;
03887   case KPT_A_Ac_B_Bc_flipAHBH:
03888     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03889       (graphData.n_A[1][move->dom] > 1) &&
03890       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03891       (graphData.n_B[1][move->dom] > 1) &&
03892       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03893       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03894       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03895                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03896     break;
03897   case KPT_A_Ac_Bc_B_flipAHBH:
03898     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03899       (graphData.n_A[1][move->dom] > 1) &&
03900       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03901       (graphData.n_B[0][move->dom] > 1) &&
03902       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03903       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03904       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03905       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03906                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
03907     break;
03908   case KPT_Ac_A_B_Bc_flipAHBH:
03909     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03910       (graphData.n_A[0][move->dom] > 1) &&
03911       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03912       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03913       (graphData.n_B[1][move->dom] > 1) &&
03914       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03915       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03916       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
03917                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03918     break;
03919   case KPT_Ac_A_Bc_B_flipAHBH:
03920     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03921       (graphData.n_A[0][move->dom] > 1) &&
03922       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03923       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03924       (graphData.n_B[0][move->dom] > 1) &&
03925       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03926       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03927       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03928       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
03929                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
03930     break;
03931   case KPT_A_Ac_B_Bc_flipBH:
03932     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03933       (graphData.n_A[1][move->dom] > 1) &&
03934       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03935       (graphData.n_B[1][move->dom] > 1) &&
03936       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03937       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03938                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03939     break;
03940   case KPT_A_Ac_Bc_B_flipBH:
03941     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03942       (graphData.n_A[1][move->dom] > 1) &&
03943       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03944       (graphData.n_B[0][move->dom] > 1) &&
03945       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03946       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03947       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03948                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
03949     break;
03950   case KPT_Ac_A_B_Bc_flipBH:
03951     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03952       (graphData.n_A[0][move->dom] > 1) &&
03953       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03954       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03955       (graphData.n_B[1][move->dom] > 1) &&
03956       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03957       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
03958                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03959     break;
03960   case KPT_Ac_A_Bc_B_flipBH:
03961     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03962       (graphData.n_A[0][move->dom] > 1) &&
03963       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03964       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03965       (graphData.n_B[0][move->dom] > 1) &&
03966       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03967       (graphData.n_BH[nodeData[move->n_id].in_BH] > 1) &&
03968       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
03969                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
03970     break;
03971   case KPT_A_Ac_B_Bc_flipAH:
03972     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03973       (graphData.n_A[1][move->dom] > 1) &&
03974       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03975       (graphData.n_B[1][move->dom] > 1) &&
03976       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03977       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03978                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03979     break;
03980   case KPT_A_Ac_Bc_B_flipAH:
03981     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03982       (graphData.n_A[1][move->dom] > 1) &&
03983       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03984       (graphData.n_B[0][move->dom] > 1) &&
03985       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03986       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03987       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipA, move->dom) &&
03988                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
03989     break;
03990   case KPT_Ac_A_B_Bc_flipAH:
03991     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
03992       (graphData.n_A[0][move->dom] > 1) &&
03993       EGbitTest (nodeData[move->n_id].It, move->dom) &&
03994       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
03995       (graphData.n_B[1][move->dom] > 1) &&
03996       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
03997       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
03998                          !EGbitTest (nodeData[move->n_id].flipB, move->dom)));
03999     break;
04000   case KPT_Ac_A_Bc_B_flipAH:
04001     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04002       (graphData.n_A[0][move->dom] > 1) &&
04003       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04004       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
04005       (graphData.n_B[0][move->dom] > 1) &&
04006       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04007       (graphData.n_AH[nodeData[move->n_id].in_AH] > 1) &&
04008       (!update_flags || (!EGbitTest (nodeData[move->n_id].flipAc, move->dom) &&
04009                          !EGbitTest (nodeData[move->n_id].flipBc, move->dom)));
04010     break;
04011   case KPT_A_Ac_B_Bc:
04012     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04013       (graphData.n_A[1][move->dom] > 1) && (!update_flags ||
04014                                             (!EGbitTest
04015                                              (nodeData[move->n_id].flipA,
04016                                               move->dom)
04017                                              &&
04018                                              !EGbitTest (nodeData[move->n_id].
04019                                                          flipB, move->dom)))
04020       && EGbitTest (nodeData[move->n_id].Ib, move->dom)
04021       && (graphData.n_B[1][move->dom] > 1);
04022     break;
04023   case KPT_A_Ac_Bc_B:
04024     rval = EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04025       (graphData.n_A[1][move->dom] > 1) && (!update_flags ||
04026                                             (!EGbitTest
04027                                              (nodeData[move->n_id].flipA,
04028                                               move->dom)
04029                                              &&
04030                                              !EGbitTest (nodeData[move->n_id].
04031                                                          flipBc, move->dom)))
04032       && !EGbitTest (nodeData[move->n_id].Ib, move->dom)
04033       && (graphData.n_B[0][move->dom] > 1)
04034       && EGbitTest (nodeData[move->n_id].It, move->dom);
04035     break;
04036   case KPT_Ac_A_B_Bc:
04037     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04038       (graphData.n_A[0][move->dom] > 1) && (!update_flags ||
04039                                             (!EGbitTest
04040                                              (nodeData[move->n_id].flipAc,
04041                                               move->dom)
04042                                              &&
04043                                              !EGbitTest (nodeData[move->n_id].
04044                                                          flipB, move->dom)))
04045       && EGbitTest (nodeData[move->n_id].It, move->dom)
04046       && EGbitTest (nodeData[move->n_id].Ib, move->dom)
04047       && (graphData.n_B[1][move->dom] > 1);
04048     break;
04049   case KPT_Ac_A_Bc_B:
04050     rval = !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04051       (graphData.n_A[0][move->dom] > 1) && (!update_flags ||
04052                                             (!EGbitTest
04053                                              (nodeData[move->n_id].flipAc,
04054                                               move->dom)
04055                                              &&
04056                                              !EGbitTest (nodeData[move->n_id].
04057                                                          flipBc, move->dom)))
04058       && EGbitTest (nodeData[move->n_id].It, move->dom)
04059       && !EGbitTest (nodeData[move->n_id].Ib, move->dom)
04060       && (graphData.n_B[0][move->dom] > 1)
04061       && EGbitTest (nodeData[move->n_id].It, move->dom);
04062     break;
04063   case KPT_AH_AHc_BHc_BH:
04064     rval = nodeData[move->n_id].in_AH && (graphData.n_AH[1] > 1) &&
04065       !nodeData[move->n_id].in_BH && (graphData.n_BH[0] > 1) &&
04066       (!update_flags || !nodeData[move->n_id].added_BH);
04067     break;
04068   case KPT_AHc_AH_BH_BHc:
04069     rval = !nodeData[move->n_id].in_AH && (graphData.n_AH[0] > 1) &&
04070       nodeData[move->n_id].in_BH && (graphData.n_BH[1] > 1) &&
04071       (!update_flags || !nodeData[move->n_id].added_AH);
04072     break;
04073   case KPT_A_Tc:
04074     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04075       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04076     rval = (type == 1U) && (graphData.n_A[1][move->dom] > 1) &&
04077       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04078       EGbitTest (nodeData[move->n_id].Ia, move->dom);
04079     break;
04080   case KPT_Ac_Tc:
04081     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04082       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04083     rval = (type == 1U) && (graphData.n_A[0][move->dom] > 1) &&
04084       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04085       !EGbitTest (nodeData[move->n_id].Ia, move->dom);
04086     break;
04087   case KPT_B_Tc:
04088     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04089       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04090     rval = (type == 2U) && (graphData.n_B[1][move->dom] > 1) &&
04091       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04092       EGbitTest (nodeData[move->n_id].Ib, move->dom);
04093     break;
04094   case KPT_Bc_Tc:
04095     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04096       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04097     rval = (type == 2U) && (graphData.n_B[0][move->dom] > 1) &&
04098       EGbitTest (nodeData[move->n_id].It, move->dom) &&
04099       !EGbitTest (nodeData[move->n_id].Ib, move->dom);
04100     break;
04101   case KPT_AB_Tc:
04102     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04103       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04104     rval = (type == 3U) && EGbitTest (nodeData[move->n_id].It, move->dom) &&
04105       EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04106       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
04107       (graphData.n_A[1][move->dom] > 1) &&
04108       (graphData.n_B[1][move->dom] > 1) && (graphData.n_AdB[1][move->dom] > 1);
04109     break;
04110   case KPT_AcB_Tc:
04111     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04112       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04113     rval = (type == 3U) && EGbitTest (nodeData[move->n_id].It, move->dom) &&
04114       !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04115       EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
04116       (graphData.n_A[0][move->dom] > 1) &&
04117       (graphData.n_B[1][move->dom] > 1) && (graphData.n_AdB[0][move->dom] > 1);
04118     break;
04119   case KPT_ABc_Tc:
04120     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04121       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04122     rval = (type == 3U) && EGbitTest (nodeData[move->n_id].It, move->dom) &&
04123       EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04124       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
04125       (graphData.n_A[1][move->dom] > 1) &&
04126       (graphData.n_B[0][move->dom] > 1) && (graphData.n_AdB[0][move->dom] > 1);
04127     break;
04128   case KPT_AcBc_Tc:
04129     type = (EGbitTest (graphData.A_partition, move->dom) ? 1U : 0U) |
04130       (EGbitTest (graphData.B_partition, move->dom) ? 2U : 0U);
04131     rval = (type == 3U) && EGbitTest (nodeData[move->n_id].It, move->dom) &&
04132       !EGbitTest (nodeData[move->n_id].Ia, move->dom) &&
04133       !EGbitTest (nodeData[move->n_id].Ib, move->dom) &&
04134       (graphData.n_A[0][move->dom] > 1) &&
04135       (graphData.n_B[0][move->dom] > 1) && (graphData.n_AdB[1][move->dom] > 1);
04136     break;
04137   case KPT_AH_AHc:
04138     rval = nodeData[move->n_id].in_AH && (graphData.n_AH[1] > 1);
04139     break;
04140   case KPT_BH_BHc:
04141     rval = nodeData[move->n_id].in_BH && (graphData.n_BH[1] > 1);
04142     break;
04143   case KPT_AH_AHc_BH_BHc:
04144     rval = nodeData[move->n_id].in_BH && (graphData.n_BH[1] > 1) &&
04145       nodeData[move->n_id].in_AH && (graphData.n_AH[1] > 1);
04146     break;
04147   case KPT_no_move:
04148     rval = 1;
04149     break;
04150   default:
04151     EXIT (1, "unknown move %d", move->move_id);
04152   }
04153   /* ending */
04154   MESSAGE (KPT_VRB, "done");
04155   return rval;
04156 }
04157 
04158 /* ========================================================================= */
04160 static inline int KPTisFullMoveFeasible (KPTFullMove_t const *const full_move)
04161 {
04162   int rval = 1;
04163   unsigned int depth = 0;
04164   MESSAGE (KPT_VRB + 19, "entering, depth %u", full_move->depth);
04165   /* check if each move is feasible, make it, and check next move */
04166   while (1)
04167   {
04168     rval = KPTisMoveFeasible (full_move->move + depth, 1);
04169     WARNINGL (KPT_EDBG, !rval, "move level %u/%u is infeasible for node %u",
04170               depth, full_move->depth, full_move->move[0].n_id);
04171     if (!rval || (depth + 1 >= full_move->depth))
04172       break;
04173     KPTmakeMove (full_move->move + depth, 0);
04174     depth++;
04175   }
04176   /* undo the moves */
04177   while (depth--)
04178     KPTmakeInvMove (full_move->move + depth, 0);
04179   MESSAGE (KPT_VRB + 19, "done, return %d", rval);
04180   return rval;
04181 }
04182 
04183 /* ========================================================================= */
04185 /* ========================================================================= */
04186 #if KPT_EDBG < DEBUG
04187 #define KPTupdateMove(__cmove,__bmove) __KPTupdateMove(__cmove,__bmove,__FILE__,__LINE__,__func__)
04188 #else
04189 #define KPTupdateMove(__cmove,__bmove) __KPTupdateMove(__cmove,__bmove)
04190 #endif
04191 static int __KPTupdateMove (const KPTFullMove_t * const cur_move,
04192                             KPTFullMove_t * const best_move
04193 #if KPT_EDBG < DEBUG
04194                             ,
04195                             const char *file,
04196                             const int line,
04197                             const char *function
04198 #endif
04199   )
04200 {
04201   if ((cur_move->val + fabs (KPTMinImprovement) < best_move->val) ||
04202       (cur_move->move[0].move_id < best_move->move[0].move_id &&
04203        (fabs (cur_move->val - best_move->val) < fabs (KPTMinImprovement))))
04204   {
04205 #if KPT_VRB+1900<DEBUG
04206     fprintf (stderr, "Storing Move for node %u\n", cur_move->move[0].n_id);
04207     {
04208       unsigned l_depth = cur_move->depth;
04209       fprintf (stderr, "New Move:\n");
04210       while (l_depth--)
04211         DPdisplaySingleMove (cur_move->move + l_depth);
04212       fprintf (stderr, "\tValue %lf\n", cur_move->val);
04213       l_depth = best_move->depth;
04214       fprintf (stderr, "Old Move:\n");
04215       while (l_depth--)
04216         DPdisplaySingleMove (best_move->move + l_depth);
04217       fprintf (stderr, "\tValue %lf\n", best_move->val);
04218     }
04219 #endif
04220 #if KPT_EDBG < DEBUG
04221     {
04222       unsigned int l_depth = cur_move->depth;
04223       while (l_depth--)
04224         EXIT (cur_move->move[l_depth].move_id == KPT_no_move,
04225               "Storing KPT_no_move for depth %u, called from %s at %s:%d",
04226               l_depth, function, file, line);
04227     }
04228 #endif
04229     memcpy (best_move, cur_move, sizeof (KPTFullMove_t));
04230 #if KPT_EDBG < DEBUG
04231     if (!KPTisFullMoveFeasible (best_move))
04232     {
04233       unsigned l_depth = best_move->depth;
04234       while (l_depth--)
04235         DPdisplaySingleMove (best_move->move + l_depth);
04236       fprintf (stderr, "\tValue %lf\n", best_move->val);
04237       WARNING (1, "Baaaaaaaaaad");
04238     }
04239 #endif
04240   }
04241   return 0;
04242 }
04243 
04244 /* ========================================================================= */
04246 /* ========================================================================= */
04247 static inline int KPTpriceBHBHc (KPTMove_t const *const cur_move,
04248                                  double *const move_val)
04249 {
04250   /* local variables */
04251   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04252   unsigned e_id;
04253 
04254   /* we have to compute every move */
04255   for (; e_it; e_it = e_it->next)
04256   {
04257     e_id = KPTgetEdgeId (e_it);
04258     /* we just flip BF */
04259     if (edgeData[e_id].num.in_BF)
04260       (*move_val) -= weight[e_id];
04261     else
04262       (*move_val) += weight[e_id];
04263   }                             /* end loop through all incident edges */
04264   return 0;
04265 }
04266 
04267 /* ========================================================================= */
04269 /* ========================================================================= */
04270 #define KPTpriceBHcBH(__move,__val) KPTpriceBHBHc(__move,__val)
04271 
04272 /* ========================================================================= */
04274 /* ========================================================================= */
04275 static inline int KPTpriceAHAHc (KPTMove_t const *const cur_move,
04276                                  double *const move_val)
04277 {
04278   /* local variables */
04279   EGlistNode_t *e_it;
04280   unsigned e_id;
04281 
04282   /* we have to compute every move */
04283   for (e_it = all_nodes[cur_move->n_id]->edges->begin; e_it; e_it = e_it->next)
04284   {
04285     e_id = KPTgetEdgeId (e_it);
04286     /* we just flip AF */
04287     if (edgeData[e_id].num.in_AF)
04288       (*move_val) -= weight[e_id];
04289     else
04290       (*move_val) += weight[e_id];
04291   }                             /* end loop through all incident edges */
04292   return 0;
04293 }
04294 
04295 /* ========================================================================= */
04297 /* ========================================================================= */
04298 #define KPTpriceAHcAH(__id,__val) KPTpriceAHAHc(__id,__val)
04299 
04300 /* ========================================================================= */
04303 /* ========================================================================= */
04304 static inline int KPTpriceAHAHcBHBHc (KPTMove_t const *const cur_move,
04305                                       double *const move_val)
04306 {
04307   /* local variables */
04308   EGlistNode_t *e_it;
04309   unsigned e_id;
04310 
04311   /* we have to compute every move */
04312   for (e_it = all_nodes[cur_move->n_id]->edges->begin; e_it; e_it = e_it->next)
04313   {
04314     e_id = KPTgetEdgeId (e_it);
04315     /* we just flip AF */
04316     if (edgeData[e_id].num.in_AF)
04317       (*move_val) -= weight[e_id];
04318     else
04319       (*move_val) += weight[e_id];
04320     /* we just flip BF */
04321     if (edgeData[e_id].num.in_BF)
04322       (*move_val) -= weight[e_id];
04323     else
04324       (*move_val) += weight[e_id];
04325   }                             /* end loop through all incident edges */
04326   return 0;
04327 }
04328 
04329 /* ========================================================================= */
04331 /* ========================================================================= */
04332 #define KPTpriceAHAHcBHcBH(__id,__val) KPTpriceAHAHcBHBHc(__id,__val)
04333 
04334 /* ========================================================================= */
04336 /* ========================================================================= */
04337 #define KPTpriceAHcAHBHBHc(__id,__val) KPTpriceAHAHcBHBHc(__id,__val)
04338 
04339 /* ========================================================================= */
04341 /* ========================================================================= */
04342 #define KPTpriceAHcAHBHcBH(__id,__val) KPTpriceAHAHcBHBHc(__id,__val)
04343 
04344 /* ========================================================================= */
04346 /* ========================================================================= */
04347 static inline int KPTpriceAcBTc (const KPTMove_t * const cur_move,
04348                                  double *const move_val)
04349 {
04350   /* local variables */
04351   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04352   unsigned int e_id,
04353     no_id,
04354     pos;
04355 
04356   /* we have to compute every move */
04357   for (; e_it; e_it = e_it->next)
04358   {
04359     e_id = KPTgetEdgeId (e_it);
04360     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04361     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04362       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
04363       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
04364     switch (pos)
04365     {
04366     case 5U:
04367       /* in this case, the only change is that we have to pay for this edge in
04368        * Delta(T) */
04369       (*move_val) += weight[e_id];
04370       break;
04371     case 3U:
04372       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
04373        * one E(B:Bc) and flip BF */
04374       (*move_val) += weight[e_id];
04375       if (edgeData[e_id].num.in_AF)
04376         (*move_val) -= 2 * weight[e_id];
04377       if (edgeData[e_id].num.in_BF)
04378         (*move_val) -= 2 * weight[e_id];
04379       break;
04380     case 1U:
04381       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
04382       if (edgeData[e_id].num.in_BF)
04383         (*move_val) -= weight[e_id];
04384       else
04385         (*move_val) += weight[e_id];
04386       break;
04387     case 7U:
04388       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
04389       if (edgeData[e_id].num.in_AF)
04390         (*move_val) -= weight[e_id];
04391       else
04392         (*move_val) += weight[e_id];
04393       break;
04394     case 0U:
04395       /* in this case we save one Delta(T) */
04396       (*move_val) -= weight[e_id];
04397       break;
04398     default:
04399       EXIT (1, "This should not happen, value %u", pos);
04400     }                           /* end switch */
04401   }                             /* end loop through all incident edges */
04402   return 0;
04403 }
04404 
04405 /* ========================================================================= */
04407 /* ========================================================================= */
04408 static inline int KPTpriceABcTc (const KPTMove_t * const cur_move,
04409                                  double *const move_val)
04410 {
04411   /* local variables */
04412   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04413   unsigned int e_id,
04414     no_id,
04415     pos;
04416 
04417   /* we have to compute every move */
04418   for (; e_it; e_it = e_it->next)
04419   {
04420     e_id = KPTgetEdgeId (e_it);
04421     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04422     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04423       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
04424       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
04425     switch (pos)
04426     {
04427     case 3U:
04428       /* in this case, the only change is that we have to pay for this edge in
04429        * Delta(T) */
04430       (*move_val) += weight[e_id];
04431       break;
04432     case 5U:
04433       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
04434        * one E(B:Bc) and flip BF */
04435       (*move_val) += weight[e_id];
04436       if (edgeData[e_id].num.in_AF)
04437         (*move_val) -= 2 * weight[e_id];
04438       if (edgeData[e_id].num.in_BF)
04439         (*move_val) -= 2 * weight[e_id];
04440       break;
04441     case 7U:
04442       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
04443       if (edgeData[e_id].num.in_BF)
04444         (*move_val) -= weight[e_id];
04445       else
04446         (*move_val) += weight[e_id];
04447       break;
04448     case 1U:
04449       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
04450       if (edgeData[e_id].num.in_AF)
04451         (*move_val) -= weight[e_id];
04452       else
04453         (*move_val) += weight[e_id];
04454       break;
04455     case 0U:
04456       /* in this case we save one Delta(T) */
04457       (*move_val) -= weight[e_id];
04458       break;
04459     default:
04460       EXIT (1, "This should not happen, value %u", pos);
04461     }                           /* end switch */
04462   }                             /* end loop through all incident edges */
04463   return 0;
04464 }
04465 
04466 /* ========================================================================= */
04468 /* ========================================================================= */
04469 static inline int KPTpriceAcBcTc (const KPTMove_t * const cur_move,
04470                                   double *const move_val)
04471 {
04472   /* local variables */
04473   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04474   unsigned int e_id,
04475     no_id,
04476     pos;
04477 
04478   /* we have to compute every move */
04479   for (; e_it; e_it = e_it->next)
04480   {
04481     e_id = KPTgetEdgeId (e_it);
04482     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04483     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04484       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
04485       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
04486     switch (pos)
04487     {
04488     case 1U:
04489       /* in this case, the only change is that we have to pay for this edge in
04490        * Delta(T) */
04491       (*move_val) += weight[e_id];
04492       break;
04493     case 7U:
04494       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
04495        * one E(B:Bc) and flip BF */
04496       (*move_val) += weight[e_id];
04497       if (edgeData[e_id].num.in_AF)
04498         (*move_val) -= 2 * weight[e_id];
04499       if (edgeData[e_id].num.in_BF)
04500         (*move_val) -= 2 * weight[e_id];
04501       break;
04502     case 5U:
04503       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
04504       if (edgeData[e_id].num.in_BF)
04505         (*move_val) -= weight[e_id];
04506       else
04507         (*move_val) += weight[e_id];
04508       break;
04509     case 3U:
04510       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
04511       if (edgeData[e_id].num.in_AF)
04512         (*move_val) -= weight[e_id];
04513       else
04514         (*move_val) += weight[e_id];
04515       break;
04516     case 0U:
04517       /* in this case we save one Delta(T) */
04518       (*move_val) -= weight[e_id];
04519       break;
04520     default:
04521       EXIT (1, "This should not happen, value %u", pos);
04522     }                           /* end switch */
04523   }                             /* end loop through all incident edges */
04524   return 0;
04525 }
04526 
04527 /* ========================================================================= */
04530 /* ========================================================================= */
04531 static inline int KPTpriceBBcflipBH (const KPTMove_t * const cur_move,
04532                                      double *const move_val)
04533 {
04534   /* local variables */
04535   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04536   unsigned int e_id,
04537     no_id,
04538     pos;
04539 
04540   /* we have to compute every move */
04541   for (; e_it; e_it = e_it->next)
04542   {
04543     e_id = KPTgetEdgeId (e_it);
04544     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04545     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04546       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 2U : 0U);
04547     switch (pos)
04548     {
04549     case 0U:
04550       /* in this case, change BH and flip BF  */
04551       if (edgeData[e_id].num.in_BF)
04552         (*move_val) -= weight[e_id];
04553       else
04554         (*move_val) += weight[e_id];
04555       break;
04556     case 1U:
04557       /* in this case we save one E(B:Bc) and double flip BF and change BH */
04558       (*move_val) -= weight[e_id];
04559       break;
04560     case 3U:
04561       /* in this case we pay one E(B:Bc) and double flip BF and change BH */
04562       (*move_val) += weight[e_id];
04563       break;
04564     default:
04565       EXIT (1, "This should not happen, value %u", pos);
04566     }                           /* end switch */
04567   }                             /* end loop through all incident edges */
04568   return 0;
04569 }
04570 
04571 /* ========================================================================= */
04573 /* ========================================================================= */
04574 static inline int KPTpriceBcBflipBH (const KPTMove_t * const cur_move,
04575                                      double *const move_val)
04576 {
04577   /* local variables */
04578   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04579   unsigned int e_id,
04580     no_id,
04581     pos;
04582 
04583   /* we have to compute every move */
04584   for (; e_it; e_it = e_it->next)
04585   {
04586     e_id = KPTgetEdgeId (e_it);
04587     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04588     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04589       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 2U : 0U);
04590     switch (pos)
04591     {
04592     case 0U:
04593       /* in this case, change BH and flip BF  */
04594       if (edgeData[e_id].num.in_BF)
04595         (*move_val) -= weight[e_id];
04596       else
04597         (*move_val) += weight[e_id];
04598       break;
04599     case 3U:
04600       /* in this case we save one E(B:Bc) and double flip BF and change BH */
04601       (*move_val) -= weight[e_id];
04602       break;
04603     case 1U:
04604       /* in this case we pay one E(B:Bc) and double flip BF and change BH */
04605       (*move_val) += weight[e_id];
04606       break;
04607     default:
04608       EXIT (1, "This should not happen, value %u", pos);
04609     }                           /* end switch */
04610   }                             /* end loop through all incident edges */
04611   return 0;
04612 }
04613 
04614 
04615 /* ========================================================================= */
04617 /* ========================================================================= */
04618 static inline int KPTpriceAAcflipAH (const KPTMove_t * const cur_move,
04619                                      double *const move_val)
04620 {
04621   /* local variables */
04622   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04623   unsigned int e_id,
04624     no_id,
04625     pos;
04626 
04627   /* we have to compute every move */
04628   for (; e_it; e_it = e_it->next)
04629   {
04630     e_id = KPTgetEdgeId (e_it);
04631     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04632     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04633       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U);
04634     switch (pos)
04635     {
04636     case 0U:
04637       /* in this case, change AH and flip AF  */
04638       if (edgeData[e_id].num.in_AF)
04639         (*move_val) -= weight[e_id];
04640       else
04641         (*move_val) += weight[e_id];
04642       break;
04643     case 1U:
04644       /* in this case we save one E(A:Ac) and double flip AF and change AH */
04645       (*move_val) -= weight[e_id];
04646       break;
04647     case 3U:
04648       /* in this case we pay one E(A:Ac) and double flip AF and change AH */
04649       (*move_val) += weight[e_id];
04650       break;
04651     default:
04652       EXIT (1, "This should not happen, value %u", pos);
04653     }                           /* end switch */
04654   }                             /* end loop through all incident edges */
04655   return 0;
04656 }
04657 
04658 /* ========================================================================= */
04660 /* ========================================================================= */
04661 static inline int KPTpriceAcAflipAH (const KPTMove_t * const cur_move,
04662                                      double *const move_val)
04663 {
04664   /* local variables */
04665   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04666   unsigned int e_id,
04667     no_id,
04668     pos;
04669 
04670   /* we have to compute every move */
04671   for (; e_it; e_it = e_it->next)
04672   {
04673     e_id = KPTgetEdgeId (e_it);
04674     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04675     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04676       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U);
04677     switch (pos)
04678     {
04679     case 0U:
04680       /* in this case, change AH and flip AF  */
04681       if (edgeData[e_id].num.in_AF)
04682         (*move_val) -= weight[e_id];
04683       else
04684         (*move_val) += weight[e_id];
04685       break;
04686     case 3U:
04687       /* in this case we save one E(A:Ac) and double flip AF and change AH */
04688       (*move_val) -= weight[e_id];
04689       break;
04690     case 1U:
04691       /* in this case we pay one E(A:Ac) and double flip AF and change AH */
04692       (*move_val) += weight[e_id];
04693       break;
04694     default:
04695       EXIT (1, "This should not happen, value %u", pos);
04696     }                           /* end switch */
04697   }                             /* end loop through all incident edges */
04698   return 0;
04699 }
04700 
04701 /* ========================================================================= */
04703 /* ========================================================================= */
04704 static inline int KPTpriceBBc (const KPTMove_t * const cur_move,
04705                                double *const move_val)
04706 {
04707   /* local variables */
04708   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04709   unsigned int e_id,
04710     no_id,
04711     pos;
04712 
04713   /* we have to compute every move */
04714   for (; e_it; e_it = e_it->next)
04715   {
04716     e_id = KPTgetEdgeId (e_it);
04717     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04718     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04719       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 2U : 0U);
04720     switch (pos)
04721     {
04722     case 0U:
04723       /* in this case, nothing happen  */
04724       break;
04725     case 1U:
04726       /* in this case we save one E(B:Bc) and flip AF */
04727       if (edgeData[e_id].num.in_BF)
04728         (*move_val) -= 2 * weight[e_id];
04729       break;
04730     case 3U:
04731       /* in this case we pay one E(B:Bc) and flip AF */
04732       if (!edgeData[e_id].num.in_BF)
04733         (*move_val) += 2 * weight[e_id];
04734       break;
04735     default:
04736       EXIT (1, "This should not happen, value %u", pos);
04737     }                           /* end switch */
04738   }                             /* end loop through all incident edges */
04739   return 0;
04740 }
04741 
04742 /* ========================================================================= */
04744 /* ========================================================================= */
04745 static inline int KPTpriceBcB (const KPTMove_t * const cur_move,
04746                                double *const move_val)
04747 {
04748   /* local variables */
04749   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04750   unsigned int e_id,
04751     no_id,
04752     pos;
04753 
04754   /* we have to compute every move */
04755   for (; e_it; e_it = e_it->next)
04756   {
04757     e_id = KPTgetEdgeId (e_it);
04758     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04759     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04760       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 2U : 0U);
04761     switch (pos)
04762     {
04763     case 0U:
04764       /* in this case, nothing happen  */
04765       break;
04766     case 3U:
04767       /* in this case we save one E(B:Bc) and flip AF */
04768       if (edgeData[e_id].num.in_BF)
04769         (*move_val) -= 2 * weight[e_id];
04770       break;
04771     case 1U:
04772       /* in this case we pay one E(B:Bc) and flip AF */
04773       if (!edgeData[e_id].num.in_BF)
04774         (*move_val) += 2 * weight[e_id];
04775       break;
04776     default:
04777       EXIT (1, "This should not happen, value %u", pos);
04778     }                           /* end switch */
04779   }                             /* end loop through all incident edges */
04780   return 0;
04781 }
04782 
04783 
04784 /* ========================================================================= */
04786 /* ========================================================================= */
04787 static inline int KPTpriceAAc (const KPTMove_t * const cur_move,
04788                                double *const move_val)
04789 {
04790   /* local variables */
04791   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04792   unsigned int e_id,
04793     no_id,
04794     pos;
04795 
04796   /* we have to compute every move */
04797   for (; e_it; e_it = e_it->next)
04798   {
04799     e_id = KPTgetEdgeId (e_it);
04800     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04801     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04802       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U);
04803     switch (pos)
04804     {
04805     case 0U:
04806       /* in this case, nothing happen  */
04807       break;
04808     case 1U:
04809       /* in this case we save one E(A:Ac) and flip AF */
04810       if (edgeData[e_id].num.in_AF)
04811         (*move_val) -= 2 * weight[e_id];
04812       break;
04813     case 3U:
04814       /* in this case we pay one E(A:Ac) and flip AF */
04815       if (!edgeData[e_id].num.in_AF)
04816         (*move_val) += 2 * weight[e_id];
04817       break;
04818     default:
04819       EXIT (1, "This should not happen, value %u", pos);
04820     }                           /* end switch */
04821   }                             /* end loop through all incident edges */
04822   return 0;
04823 }
04824 
04825 /* ========================================================================= */
04827 /* ========================================================================= */
04828 static inline int KPTpriceAcA (const KPTMove_t * const cur_move,
04829                                double *const move_val)
04830 {
04831   /* local variables */
04832   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04833   unsigned int e_id,
04834     no_id,
04835     pos;
04836 
04837   /* we have to compute every move */
04838   for (; e_it; e_it = e_it->next)
04839   {
04840     e_id = KPTgetEdgeId (e_it);
04841     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04842     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04843       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U);
04844     switch (pos)
04845     {
04846     case 0U:
04847       /* in this case, nothing happen  */
04848       break;
04849     case 3U:
04850       /* in this case we save one E(A:Ac) and flip AF */
04851       if (edgeData[e_id].num.in_AF)
04852         (*move_val) -= 2 * weight[e_id];
04853       break;
04854     case 1U:
04855       /* in this case we pay one E(A:Ac) and flip AF */
04856       if (!edgeData[e_id].num.in_AF)
04857         (*move_val) += 2 * weight[e_id];
04858       break;
04859     default:
04860       EXIT (1, "This should not happen, value %u", pos);
04861     }                           /* end switch */
04862   }                             /* end loop through all incident edges */
04863   return 0;
04864 }
04865 
04866 /* ========================================================================= */
04869 /* ========================================================================= */
04870 static inline int KPTpriceAcABBc (const KPTMove_t * const cur_move,
04871                                   double *const move_val)
04872 {
04873   /* local variables */
04874   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04875   unsigned int e_id,
04876     no_id,
04877     pos;
04878 
04879   /* we have to compute every move */
04880   for (; e_it; e_it = e_it->next)
04881   {
04882     e_id = KPTgetEdgeId (e_it);
04883     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04884     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04885       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
04886       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
04887     switch (pos)
04888     {
04889     case 0U:
04890       /* in this case, nothing happen */
04891       break;
04892     case 3U:
04893       /* in this case we save one E(A:Ac) and flip AF, save 
04894        * one E(B:Bc) and flip BF */
04895       if (edgeData[e_id].num.in_AF)
04896         (*move_val) -= 2 * weight[e_id];
04897       if (edgeData[e_id].num.in_BF)
04898         (*move_val) -= 2 * weight[e_id];
04899       break;
04900     case 1U:
04901       /* in this case we pay one E(A:Ac) and flip AF, save 
04902        * one E(B:Bc) and flip BF */
04903       if (!edgeData[e_id].num.in_AF)
04904         (*move_val) += 2 * weight[e_id];
04905       if (edgeData[e_id].num.in_BF)
04906         (*move_val) -= 2 * weight[e_id];
04907       break;
04908     case 7U:
04909       /* in this case we save one E(A:Ac) and flip AF, pay 
04910        * one E(B:Bc) and flip BF */
04911       if (edgeData[e_id].num.in_AF)
04912         (*move_val) -= 2 * weight[e_id];
04913       if (!edgeData[e_id].num.in_BF)
04914         (*move_val) += 2 * weight[e_id];
04915       break;
04916     case 5U:
04917       /* in this case we pay one E(A:Ac) and flip AF, pay 
04918        * one E(B:Bc) and flip BF */
04919       if (!edgeData[e_id].num.in_AF)
04920         (*move_val) += 2 * weight[e_id];
04921       if (!edgeData[e_id].num.in_BF)
04922         (*move_val) += 2 * weight[e_id];
04923       break;
04924     default:
04925       EXIT (1, "This should not happen, value %u", pos);
04926     }                           /* end switch */
04927   }                             /* end loop through all incident edges */
04928   return 0;
04929 }
04930 
04931 /* ========================================================================= */
04934 /* ========================================================================= */
04935 static inline int KPTpriceAAcBcB (const KPTMove_t * const cur_move,
04936                                   double *const move_val)
04937 {
04938   /* local variables */
04939   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
04940   unsigned int e_id,
04941     no_id,
04942     pos;
04943 
04944   /* we have to compute every move */
04945   for (; e_it; e_it = e_it->next)
04946   {
04947     e_id = KPTgetEdgeId (e_it);
04948     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
04949     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
04950       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
04951       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
04952     switch (pos)
04953     {
04954     case 0U:
04955       /* in this case, nothing happen */
04956       break;
04957     case 5U:
04958       /* in this case we save one E(A:Ac) and flip AF, save 
04959        * one E(B:Bc) and flip BF */
04960       if (edgeData[e_id].num.in_AF)
04961         (*move_val) -= 2 * weight[e_id];
04962       if (edgeData[e_id].num.in_BF)
04963         (*move_val) -= 2 * weight[e_id];
04964       break;
04965     case 7U:
04966       /* in this case we pay one E(A:Ac) and flip AF, save 
04967        * one E(B:Bc) and flip BF */
04968       if (!edgeData[e_id].num.in_AF)
04969         (*move_val) += 2 * weight[e_id];
04970       if (edgeData[e_id].num.in_BF)
04971         (*move_val) -= 2 * weight[e_id];
04972       break;
04973     case 1U:
04974       /* in this case we save one E(A:Ac) and flip AF, pay 
04975        * one E(B:Bc) and flip BF */
04976       if (edgeData[e_id].num.in_AF)
04977         (*move_val) -= 2 * weight[e_id];
04978       if (!edgeData[e_id].num.in_BF)
04979         (*move_val) += 2 * weight[e_id];
04980       break;
04981     case 3U:
04982       /* in this case we pay one E(A:Ac) and flip AF, pay 
04983        * one E(B:Bc) and flip BF */
04984       if (!edgeData[e_id].num.in_AF)
04985         (*move_val) += 2 * weight[e_id];
04986       if (!edgeData[e_id].num.in_BF)
04987         (*move_val) += 2 * weight[e_id];
04988       break;
04989     default:
04990       EXIT (1, "This should not happen, value %u", pos);
04991     }                           /* end switch */
04992   }                             /* end loop through all incident edges */
04993   return 0;
04994 }
04995 
04996 /* ========================================================================= */
04999 /* ========================================================================= */
05000 static inline int KPTpriceAcABcB (const KPTMove_t * const cur_move,
05001                                   double *const move_val)
05002 {
05003   /* local variables */
05004   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05005   unsigned int e_id,
05006     no_id,
05007     pos;
05008 
05009   /* we have to compute every move */
05010   for (; e_it; e_it = e_it->next)
05011   {
05012     e_id = KPTgetEdgeId (e_it);
05013     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05014     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05015       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05016       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05017     switch (pos)
05018     {
05019     case 0U:
05020       /* in this case, nothing happen */
05021       break;
05022     case 7U:
05023       /* in this case we save one E(A:Ac) and flip AF, save 
05024        * one E(B:Bc) and flip BF */
05025       if (edgeData[e_id].num.in_AF)
05026         (*move_val) -= 2 * weight[e_id];
05027       if (edgeData[e_id].num.in_BF)
05028         (*move_val) -= 2 * weight[e_id];
05029       break;
05030     case 5U:
05031       /* in this case we pay one E(A:Ac) and flip AF, save 
05032        * one E(B:Bc) and flip BF */
05033       if (!edgeData[e_id].num.in_AF)
05034         (*move_val) += 2 * weight[e_id];
05035       if (edgeData[e_id].num.in_BF)
05036         (*move_val) -= 2 * weight[e_id];
05037       break;
05038     case 3U:
05039       /* in this case we save one E(A:Ac) and flip AF, pay 
05040        * one E(B:Bc) and flip BF */
05041       if (edgeData[e_id].num.in_AF)
05042         (*move_val) -= 2 * weight[e_id];
05043       if (!edgeData[e_id].num.in_BF)
05044         (*move_val) += 2 * weight[e_id];
05045       break;
05046     case 1U:
05047       /* in this case we pay one E(A:Ac) and flip AF, pay 
05048        * one E(B:Bc) and flip BF */
05049       if (!edgeData[e_id].num.in_AF)
05050         (*move_val) += 2 * weight[e_id];
05051       if (!edgeData[e_id].num.in_BF)
05052         (*move_val) += 2 * weight[e_id];
05053       break;
05054     default:
05055       EXIT (1, "This should not happen, value %u", pos);
05056     }                           /* end switch */
05057   }                             /* end loop through all incident edges */
05058   return 0;
05059 }
05060 
05061 /* ========================================================================= */
05064 /* ========================================================================= */
05065 static inline int KPTpriceAAcBBc (const KPTMove_t * const cur_move,
05066                                   double *const move_val)
05067 {
05068   /* local variables */
05069   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05070   unsigned int e_id,
05071     no_id,
05072     pos;
05073 
05074   /* we have to compute every move */
05075   for (; e_it; e_it = e_it->next)
05076   {
05077     e_id = KPTgetEdgeId (e_it);
05078     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05079     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05080       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05081       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05082     switch (pos)
05083     {
05084     case 0U:
05085       /* in this case, nothing happen */
05086       break;
05087     case 1U:
05088       /* in this case we save one E(A:Ac) and flip AF, save 
05089        * one E(B:Bc) and flip BF */
05090       if (edgeData[e_id].num.in_AF)
05091         (*move_val) -= 2 * weight[e_id];
05092       if (edgeData[e_id].num.in_BF)
05093         (*move_val) -= 2 * weight[e_id];
05094       break;
05095     case 3U:
05096       /* in this case we pay one E(A:Ac) and flip AF, save 
05097        * one E(B:Bc) and flip BF */
05098       if (!edgeData[e_id].num.in_AF)
05099         (*move_val) += 2 * weight[e_id];
05100       if (edgeData[e_id].num.in_BF)
05101         (*move_val) -= 2 * weight[e_id];
05102       break;
05103     case 5U:
05104       /* in this case we save one E(A:Ac) and flip AF, pay 
05105        * one E(B:Bc) and flip BF */
05106       if (edgeData[e_id].num.in_AF)
05107         (*move_val) -= 2 * weight[e_id];
05108       if (!edgeData[e_id].num.in_BF)
05109         (*move_val) += 2 * weight[e_id];
05110       break;
05111     case 7U:
05112       /* in this case we pay one E(A:Ac) and flip AF, pay 
05113        * one E(B:Bc) and flip BF */
05114       if (!edgeData[e_id].num.in_AF)
05115         (*move_val) += 2 * weight[e_id];
05116       if (!edgeData[e_id].num.in_BF)
05117         (*move_val) += 2 * weight[e_id];
05118       break;
05119     default:
05120       EXIT (1, "This should not happen, value %u", pos);
05121     }                           /* end switch */
05122   }                             /* end loop through all incident edges */
05123   return 0;
05124 }
05125 
05126 /* ========================================================================= */
05129 /* ========================================================================= */
05130 static inline int KPTpriceAcABBcBH (const KPTMove_t * const cur_move,
05131                                     double *const move_val)
05132 {
05133   /* local variables */
05134   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05135   unsigned int e_id,
05136     no_id,
05137     pos;
05138 
05139   /* we have to compute every move */
05140   for (; e_it; e_it = e_it->next)
05141   {
05142     e_id = KPTgetEdgeId (e_it);
05143     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05144     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05145       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05146       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05147     switch (pos)
05148     {
05149     case 0U:
05150       /* in this case, flip BH */
05151       if (edgeData[e_id].num.in_BF)
05152         (*move_val) -= weight[e_id];
05153       else
05154         (*move_val) += weight[e_id];
05155       break;
05156     case 3U:
05157       /* in this case we save one E(A:Ac) and flip AF, save 
05158        * one E(B:Bc) and double flip BF */
05159       if (edgeData[e_id].num.in_AF)
05160         (*move_val) -= 2 * weight[e_id];
05161       (*move_val) -= weight[e_id];
05162       break;
05163     case 1U:
05164       /* in this case we pay one E(A:Ac) and flip AF, save 
05165        * one E(B:Bc) and double flip BF */
05166       if (!edgeData[e_id].num.in_AF)
05167         (*move_val) += 2 * weight[e_id];
05168       (*move_val) -= weight[e_id];
05169       break;
05170     case 7U:
05171       /* in this case we save one E(A:Ac) and flip AF, pay 
05172        * one E(B:Bc) and double flip BF */
05173       if (edgeData[e_id].num.in_AF)
05174         (*move_val) -= 2 * weight[e_id];
05175       (*move_val) += weight[e_id];
05176       break;
05177     case 5U:
05178       /* in this case we pay one E(A:Ac) and flip AF, pay 
05179        * one E(B:Bc) and flip BF */
05180       if (!edgeData[e_id].num.in_AF)
05181         (*move_val) += 2 * weight[e_id];
05182       (*move_val) += weight[e_id];
05183       break;
05184     default:
05185       EXIT (1, "This should not happen, value %u", pos);
05186     }                           /* end switch */
05187   }                             /* end loop through all incident edges */
05188   return 0;
05189 }
05190 
05191 /* ========================================================================= */
05194 /* ========================================================================= */
05195 static inline int KPTpriceAAcBcBBH (const KPTMove_t * const cur_move,
05196                                     double *const move_val)
05197 {
05198   /* local variables */
05199   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05200   unsigned int e_id,
05201     no_id,
05202     pos;
05203 
05204   /* we have to compute every move */
05205   for (; e_it; e_it = e_it->next)
05206   {
05207     e_id = KPTgetEdgeId (e_it);
05208     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05209     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05210       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05211       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05212     switch (pos)
05213     {
05214     case 0U:
05215       /* in this case, flip BH */
05216       if (edgeData[e_id].num.in_BF)
05217         (*move_val) -= weight[e_id];
05218       else
05219         (*move_val) += weight[e_id];
05220       break;
05221     case 5U:
05222       /* in this case we save one E(A:Ac) and flip AF, save 
05223        * one E(B:Bc) and double flip BF */
05224       if (edgeData[e_id].num.in_AF)
05225         (*move_val) -= 2 * weight[e_id];
05226       (*move_val) -= weight[e_id];
05227       break;
05228     case 7U:
05229       /* in this case we pay one E(A:Ac) and flip AF, save 
05230        * one E(B:Bc) and double flip BF */
05231       if (!edgeData[e_id].num.in_AF)
05232         (*move_val) += 2 * weight[e_id];
05233       (*move_val) -= weight[e_id];
05234       break;
05235     case 1U:
05236       /* in this case we save one E(A:Ac) and flip AF, pay 
05237        * one E(B:Bc) and double flip BF */
05238       if (edgeData[e_id].num.in_AF)
05239         (*move_val) -= 2 * weight[e_id];
05240       (*move_val) += weight[e_id];
05241       break;
05242     case 3U:
05243       /* in this case we pay one E(A:Ac) and flip AF, pay 
05244        * one E(B:Bc) and double flip BF */
05245       if (!edgeData[e_id].num.in_AF)
05246         (*move_val) += 2 * weight[e_id];
05247       (*move_val) += weight[e_id];
05248       break;
05249     default:
05250       EXIT (1, "This should not happen, value %u", pos);
05251     }                           /* end switch */
05252   }                             /* end loop through all incident edges */
05253   return 0;
05254 }
05255 
05256 /* ========================================================================= */
05259 /* ========================================================================= */
05260 static inline int KPTpriceAcABcBBH (const KPTMove_t * const cur_move,
05261                                     double *const move_val)
05262 {
05263   /* local variables */
05264   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05265   unsigned int e_id,
05266     no_id,
05267     pos;
05268 
05269   /* we have to compute every move */
05270   for (; e_it; e_it = e_it->next)
05271   {
05272     e_id = KPTgetEdgeId (e_it);
05273     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05274     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05275       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05276       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05277     switch (pos)
05278     {
05279     case 0U:
05280       /* in this case, flip BH */
05281       if (edgeData[e_id].num.in_BF)
05282         (*move_val) -= weight[e_id];
05283       else
05284         (*move_val) += weight[e_id];
05285       break;
05286     case 7U:
05287       /* in this case we save one E(A:Ac) and flip AF, save 
05288        * one E(B:Bc) and double flip BF */
05289       if (edgeData[e_id].num.in_AF)
05290         (*move_val) -= 2 * weight[e_id];
05291       (*move_val) -= weight[e_id];
05292       break;
05293     case 5U:
05294       /* in this case we pay one E(A:Ac) and flip AF, save 
05295        * one E(B:Bc) and double flip BF */
05296       if (!edgeData[e_id].num.in_AF)
05297         (*move_val) += 2 * weight[e_id];
05298       (*move_val) -= weight[e_id];
05299       break;
05300     case 3U:
05301       /* in this case we save one E(A:Ac) and flip AF, pay 
05302        * one E(B:Bc) and double flip BF */
05303       if (edgeData[e_id].num.in_AF)
05304         (*move_val) -= 2 * weight[e_id];
05305       (*move_val) += weight[e_id];
05306       break;
05307     case 1U:
05308       /* in this case we pay one E(A:Ac) and flip AF, pay 
05309        * one E(B:Bc) and double flip BF */
05310       if (!edgeData[e_id].num.in_AF)
05311         (*move_val) += 2 * weight[e_id];
05312       (*move_val) += weight[e_id];
05313       break;
05314     default:
05315       EXIT (1, "This should not happen, value %u", pos);
05316     }                           /* end switch */
05317   }                             /* end loop through all incident edges */
05318   return 0;
05319 }
05320 
05321 /* ========================================================================= */
05324 /* ========================================================================= */
05325 static inline int KPTpriceAAcBBcBH (const KPTMove_t * const cur_move,
05326                                     double *const move_val)
05327 {
05328   /* local variables */
05329   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05330   unsigned int e_id,
05331     no_id,
05332     pos;
05333 
05334   /* we have to compute every move */
05335   for (; e_it; e_it = e_it->next)
05336   {
05337     e_id = KPTgetEdgeId (e_it);
05338     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05339     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05340       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05341       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05342     switch (pos)
05343     {
05344     case 0U:
05345       /* in this case, flip BH */
05346       if (edgeData[e_id].num.in_BF)
05347         (*move_val) -= weight[e_id];
05348       else
05349         (*move_val) += weight[e_id];
05350       break;
05351     case 1U:
05352       /* in this case we save one E(A:Ac) and flip AF, save 
05353        * one E(B:Bc) and double flip BF */
05354       if (edgeData[e_id].num.in_AF)
05355         (*move_val) -= 2 * weight[e_id];
05356       (*move_val) -= weight[e_id];
05357       break;
05358     case 3U:
05359       /* in this case we pay one E(A:Ac) and flip AF, save 
05360        * one E(B:Bc) and double flip BF */
05361       if (!edgeData[e_id].num.in_AF)
05362         (*move_val) += 2 * weight[e_id];
05363       (*move_val) -= weight[e_id];
05364       break;
05365     case 5U:
05366       /* in this case we save one E(A:Ac) and flip AF, pay 
05367        * one E(B:Bc) and double flip BF */
05368       if (edgeData[e_id].num.in_AF)
05369         (*move_val) -= 2 * weight[e_id];
05370       (*move_val) += weight[e_id];
05371       break;
05372     case 7U:
05373       /* in this case we pay one E(A:Ac) and flip AF, pay 
05374        * one E(B:Bc) and double flip BF */
05375       if (!edgeData[e_id].num.in_AF)
05376         (*move_val) += 2 * weight[e_id];
05377       (*move_val) += weight[e_id];
05378       break;
05379     default:
05380       EXIT (1, "This should not happen, value %u", pos);
05381     }                           /* end switch */
05382   }                             /* end loop through all incident edges */
05383   return 0;
05384 }
05385 
05386 /* ========================================================================= */
05389 /* ========================================================================= */
05390 static inline int KPTpriceAcABBcAH (const KPTMove_t * const cur_move,
05391                                     double *const move_val)
05392 {
05393   /* local variables */
05394   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05395   unsigned int e_id,
05396     no_id,
05397     pos;
05398 
05399   /* we have to compute every move */
05400   for (; e_it; e_it = e_it->next)
05401   {
05402     e_id = KPTgetEdgeId (e_it);
05403     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05404     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05405       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05406       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05407     switch (pos)
05408     {
05409     case 0U:
05410       /* in this case, flip AH */
05411       if (edgeData[e_id].num.in_AF)
05412         (*move_val) -= weight[e_id];
05413       else
05414         (*move_val) += weight[e_id];
05415       break;
05416     case 3U:
05417       /* in this case we save one E(A:Ac) and double flip AF, save 
05418        * one E(B:Bc) and flip BF */
05419       (*move_val) -= weight[e_id];
05420       if (edgeData[e_id].num.in_BF)
05421         (*move_val) -= 2 * weight[e_id];
05422       break;
05423     case 1U:
05424       /* in this case we pay one E(A:Ac) and double flip AF, save 
05425        * one E(B:Bc) and flip BF */
05426       (*move_val) += weight[e_id];
05427       if (edgeData[e_id].num.in_BF)
05428         (*move_val) -= 2 * weight[e_id];
05429       break;
05430     case 7U:
05431       /* in this case we save one E(A:Ac) and double flip AF, pay 
05432        * one E(B:Bc) and flip BF */
05433       (*move_val) -= weight[e_id];
05434       if (!edgeData[e_id].num.in_BF)
05435         (*move_val) += 2 * weight[e_id];
05436       break;
05437     case 5U:
05438       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05439        * one E(B:Bc) and flip BF */
05440       (*move_val) += weight[e_id];
05441       if (!edgeData[e_id].num.in_BF)
05442         (*move_val) += 2 * weight[e_id];
05443       break;
05444     default:
05445       EXIT (1, "This should not happen, value %u", pos);
05446     }                           /* end switch */
05447   }                             /* end loop through all incident edges */
05448   return 0;
05449 }
05450 
05451 /* ========================================================================= */
05454 /* ========================================================================= */
05455 static inline int KPTpriceAAcBcBAH (const KPTMove_t * const cur_move,
05456                                     double *const move_val)
05457 {
05458   /* local variables */
05459   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05460   unsigned int e_id,
05461     no_id,
05462     pos;
05463 
05464   /* we have to compute every move */
05465   for (; e_it; e_it = e_it->next)
05466   {
05467     e_id = KPTgetEdgeId (e_it);
05468     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05469     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05470       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05471       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05472     switch (pos)
05473     {
05474     case 0U:
05475       /* in this case, flip AF */
05476       if (edgeData[e_id].num.in_AF)
05477         (*move_val) -= weight[e_id];
05478       else
05479         (*move_val) += weight[e_id];
05480       break;
05481     case 5U:
05482       /* in this case we save one E(A:Ac) and double flip AF, save 
05483        * one E(B:Bc) and flip BF */
05484       (*move_val) -= weight[e_id];
05485       if (edgeData[e_id].num.in_BF)
05486         (*move_val) -= 2 * weight[e_id];
05487       break;
05488     case 7U:
05489       /* in this case we pay one E(A:Ac) and double flip AF, save 
05490        * one E(B:Bc) and flip BF */
05491       (*move_val) += weight[e_id];
05492       if (edgeData[e_id].num.in_BF)
05493         (*move_val) -= 2 * weight[e_id];
05494       break;
05495     case 1U:
05496       /* in this case we save one E(A:Ac) and double flip AF, pay 
05497        * one E(B:Bc) and flip BF */
05498       (*move_val) -= weight[e_id];
05499       if (!edgeData[e_id].num.in_BF)
05500         (*move_val) += 2 * weight[e_id];
05501       break;
05502     case 3U:
05503       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05504        * one E(B:Bc) and flip BF */
05505       (*move_val) += weight[e_id];
05506       if (!edgeData[e_id].num.in_BF)
05507         (*move_val) += 2 * weight[e_id];
05508       break;
05509     default:
05510       EXIT (1, "This should not happen, value %u", pos);
05511     }                           /* end switch */
05512   }                             /* end loop through all incident edges */
05513   return 0;
05514 }
05515 
05516 /* ========================================================================= */
05519 /* ========================================================================= */
05520 static inline int KPTpriceAcABcBAH (const KPTMove_t * const cur_move,
05521                                     double *const move_val)
05522 {
05523   /* local variables */
05524   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05525   unsigned int e_id,
05526     no_id,
05527     pos;
05528 
05529   /* we have to compute every move */
05530   for (; e_it; e_it = e_it->next)
05531   {
05532     e_id = KPTgetEdgeId (e_it);
05533     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05534     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05535       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05536       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05537     switch (pos)
05538     {
05539     case 0U:
05540       /* in this case, flip AH */
05541       if (edgeData[e_id].num.in_AF)
05542         (*move_val) -= weight[e_id];
05543       else
05544         (*move_val) += weight[e_id];
05545       break;
05546     case 7U:
05547       /* in this case we save one E(A:Ac) and double flip AF, save 
05548        * one E(B:Bc) and flip BF */
05549       (*move_val) -= weight[e_id];
05550       if (edgeData[e_id].num.in_BF)
05551         (*move_val) -= 2 * weight[e_id];
05552       break;
05553     case 5U:
05554       /* in this case we pay one E(A:Ac) and double flip AF, save 
05555        * one E(B:Bc) and flip BF */
05556       (*move_val) += weight[e_id];
05557       if (edgeData[e_id].num.in_BF)
05558         (*move_val) -= 2 * weight[e_id];
05559       break;
05560     case 3U:
05561       /* in this case we save one E(A:Ac) and double flip AF, pay 
05562        * one E(B:Bc) and flip BF */
05563       (*move_val) -= weight[e_id];
05564       if (!edgeData[e_id].num.in_BF)
05565         (*move_val) += 2 * weight[e_id];
05566       break;
05567     case 1U:
05568       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05569        * one E(B:Bc) and flip BF */
05570       (*move_val) += weight[e_id];
05571       if (!edgeData[e_id].num.in_BF)
05572         (*move_val) += 2 * weight[e_id];
05573       break;
05574     default:
05575       EXIT (1, "This should not happen, value %u", pos);
05576     }                           /* end switch */
05577   }                             /* end loop through all incident edges */
05578   return 0;
05579 }
05580 
05581 /* ========================================================================= */
05584 /* ========================================================================= */
05585 static inline int KPTpriceAAcBBcAH (const KPTMove_t * const cur_move,
05586                                     double *const move_val)
05587 {
05588   /* local variables */
05589   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05590   unsigned int e_id,
05591     no_id,
05592     pos;
05593 
05594   /* we have to compute every move */
05595   for (; e_it; e_it = e_it->next)
05596   {
05597     e_id = KPTgetEdgeId (e_it);
05598     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05599     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05600       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05601       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05602     switch (pos)
05603     {
05604     case 0U:
05605       /* in this case, flip AH */
05606       if (edgeData[e_id].num.in_AF)
05607         (*move_val) -= weight[e_id];
05608       else
05609         (*move_val) += weight[e_id];
05610       break;
05611     case 1U:
05612       /* in this case we save one E(A:Ac) and double flip AF, save 
05613        * one E(B:Bc) and flip BF */
05614       (*move_val) -= weight[e_id];
05615       if (edgeData[e_id].num.in_BF)
05616         (*move_val) -= 2 * weight[e_id];
05617       break;
05618     case 3U:
05619       /* in this case we pay one E(A:Ac) and double flip AF, save 
05620        * one E(B:Bc) and flip BF */
05621       (*move_val) += weight[e_id];
05622       if (edgeData[e_id].num.in_BF)
05623         (*move_val) -= 2 * weight[e_id];
05624       break;
05625     case 5U:
05626       /* in this case we save one E(A:Ac) and double flip AF, pay 
05627        * one E(B:Bc) and flip BF */
05628       (*move_val) -= weight[e_id];
05629       if (!edgeData[e_id].num.in_BF)
05630         (*move_val) += 2 * weight[e_id];
05631       break;
05632     case 7U:
05633       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05634        * one E(B:Bc) and flip BF */
05635       (*move_val) += weight[e_id];
05636       if (!edgeData[e_id].num.in_BF)
05637         (*move_val) += 2 * weight[e_id];
05638       break;
05639     default:
05640       EXIT (1, "This should not happen, value %u", pos);
05641     }                           /* end switch */
05642   }                             /* end loop through all incident edges */
05643   return 0;
05644 }
05645 
05646 /* ========================================================================= */
05649 /* ========================================================================= */
05650 static inline int KPTpriceAcABBcAHBH (const KPTMove_t * const cur_move,
05651                                       double *const move_val)
05652 {
05653   /* local variables */
05654   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05655   unsigned int e_id,
05656     no_id,
05657     pos;
05658 
05659   /* we have to compute every move */
05660   for (; e_it; e_it = e_it->next)
05661   {
05662     e_id = KPTgetEdgeId (e_it);
05663     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05664     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05665       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05666       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05667     switch (pos)
05668     {
05669     case 0U:
05670       /* in this case, flip AF and flip BF */
05671       if (edgeData[e_id].num.in_AF)
05672         (*move_val) -= weight[e_id];
05673       else
05674         (*move_val) += weight[e_id];
05675       if (edgeData[e_id].num.in_BF)
05676         (*move_val) -= weight[e_id];
05677       else
05678         (*move_val) += weight[e_id];
05679       break;
05680     case 3U:
05681       /* in this case we save one E(A:Ac) and double flip AF, save 
05682        * one E(B:Bc) and double flip BF */
05683       (*move_val) -= 2 * weight[e_id];
05684       break;
05685     case 1U:
05686       /* in this case we pay one E(A:Ac) and double flip AF, save 
05687        * one E(B:Bc) and double flip BF */
05688       break;
05689     case 7U:
05690       /* in this case we save one E(A:Ac) and double flip AF, pay 
05691        * one E(B:Bc) and double flip BF */
05692       break;
05693     case 5U:
05694       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05695        * one E(B:Bc) and double flip BF */
05696       (*move_val) += 2 * weight[e_id];
05697       break;
05698     default:
05699       EXIT (1, "This should not happen, value %u", pos);
05700     }                           /* end switch */
05701   }                             /* end loop through all incident edges */
05702   return 0;
05703 }
05704 
05705 /* ========================================================================= */
05708 /* ========================================================================= */
05709 static inline int KPTpriceAAcBcBAHBH (const KPTMove_t * const cur_move,
05710                                       double *const move_val)
05711 {
05712   /* local variables */
05713   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05714   unsigned int e_id,
05715     no_id,
05716     pos;
05717 
05718   /* we have to compute every move */
05719   for (; e_it; e_it = e_it->next)
05720   {
05721     e_id = KPTgetEdgeId (e_it);
05722     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05723     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05724       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05725       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05726     switch (pos)
05727     {
05728     case 0U:
05729       /* in this case, flip AF and flip BF */
05730       if (edgeData[e_id].num.in_AF)
05731         (*move_val) -= weight[e_id];
05732       else
05733         (*move_val) += weight[e_id];
05734       if (edgeData[e_id].num.in_BF)
05735         (*move_val) -= weight[e_id];
05736       else
05737         (*move_val) += weight[e_id];
05738       break;
05739     case 5U:
05740       /* in this case we save one E(A:Ac) and double flip AF, save 
05741        * one E(B:Bc) and double flip BF */
05742       (*move_val) -= 2 * weight[e_id];
05743       break;
05744     case 7U:
05745       /* in this case we pay one E(A:Ac) and double flip AF, save 
05746        * one E(B:Bc) and double flip BF */
05747       break;
05748     case 1U:
05749       /* in this case we save one E(A:Ac) and double flip AF, pay 
05750        * one E(B:Bc) and double flip BF */
05751       break;
05752     case 3U:
05753       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05754        * one E(B:Bc) and double flip BF */
05755       (*move_val) += 2 * weight[e_id];
05756       break;
05757     default:
05758       EXIT (1, "This should not happen, value %u", pos);
05759     }                           /* end switch */
05760   }                             /* end loop through all incident edges */
05761   return 0;
05762 }
05763 
05764 /* ========================================================================= */
05767 /* ========================================================================= */
05768 static inline int KPTpriceAcABcBAHBH (const KPTMove_t * const cur_move,
05769                                       double *const move_val)
05770 {
05771   /* local variables */
05772   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05773   unsigned int e_id,
05774     no_id,
05775     pos;
05776 
05777   /* we have to compute every move */
05778   for (; e_it; e_it = e_it->next)
05779   {
05780     e_id = KPTgetEdgeId (e_it);
05781     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05782     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05783       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05784       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05785     switch (pos)
05786     {
05787     case 0U:
05788       /* in this case, flip AF and flip BF */
05789       if (edgeData[e_id].num.in_AF)
05790         (*move_val) -= weight[e_id];
05791       else
05792         (*move_val) += weight[e_id];
05793       if (edgeData[e_id].num.in_BF)
05794         (*move_val) -= weight[e_id];
05795       else
05796         (*move_val) += weight[e_id];
05797       break;
05798     case 7U:
05799       /* in this case we save one E(A:Ac) and double flip AF, save 
05800        * one E(B:Bc) and double flip BF */
05801       (*move_val) -= 2 * weight[e_id];
05802       break;
05803     case 5U:
05804       /* in this case we pay one E(A:Ac) and double flip AF, save 
05805        * one E(B:Bc) and double flip BF */
05806       break;
05807     case 3U:
05808       /* in this case we save one E(A:Ac) and double flip AF, pay 
05809        * one E(B:Bc) and double flip BF */
05810       break;
05811     case 1U:
05812       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05813        * one E(B:Bc) and double flip BF */
05814       (*move_val) += 2 * weight[e_id];
05815       break;
05816     default:
05817       EXIT (1, "This should not happen, value %u", pos);
05818     }                           /* end switch */
05819   }                             /* end loop through all incident edges */
05820   return 0;
05821 }
05822 
05823 /* ========================================================================= */
05826 /* ========================================================================= */
05827 static inline int KPTpriceAAcBBcAHBH (const KPTMove_t * const cur_move,
05828                                       double *const move_val)
05829 {
05830   /* local variables */
05831   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05832   unsigned int e_id,
05833     no_id,
05834     pos;
05835 
05836   /* we have to compute every move */
05837   for (; e_it; e_it = e_it->next)
05838   {
05839     e_id = KPTgetEdgeId (e_it);
05840     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05841     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05842       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05843       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05844     switch (pos)
05845     {
05846     case 0U:
05847       /* in this case, flip AF and flip BF */
05848       if (edgeData[e_id].num.in_AF)
05849         (*move_val) -= weight[e_id];
05850       else
05851         (*move_val) += weight[e_id];
05852       if (edgeData[e_id].num.in_BF)
05853         (*move_val) -= weight[e_id];
05854       else
05855         (*move_val) += weight[e_id];
05856       break;
05857     case 1U:
05858       /* in this case we save one E(A:Ac) and double flip AF, save 
05859        * one E(B:Bc) and double flip BF */
05860       (*move_val) -= 2 * weight[e_id];
05861       break;
05862     case 3U:
05863       /* in this case we pay one E(A:Ac) and double flip AF, save 
05864        * one E(B:Bc) and double flip BF */
05865       break;
05866     case 5U:
05867       /* in this case we save one E(A:Ac) and double flip AF, pay 
05868        * one E(B:Bc) and double flip BF */
05869       break;
05870     case 7U:
05871       /* in this case we pay one E(A:Ac) and double flip AF, pay 
05872        * one E(B:Bc) and double flip BF */
05873       (*move_val) += 2 * weight[e_id];
05874       break;
05875     default:
05876       EXIT (1, "This should not happen, value %u", pos);
05877     }                           /* end switch */
05878   }                             /* end loop through all incident edges */
05879   return 0;
05880 }
05881 
05882 
05883 /* ========================================================================= */
05885 /* ========================================================================= */
05886 static inline int KPTpriceABTc (const KPTMove_t * const cur_move,
05887                                 double *const move_val)
05888 {
05889   /* local variables */
05890   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05891   unsigned int e_id,
05892     no_id,
05893     pos;
05894 
05895   /* we have to compute every move */
05896   for (; e_it; e_it = e_it->next)
05897   {
05898     e_id = KPTgetEdgeId (e_it);
05899     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05900     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05901       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05902       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05903     switch (pos)
05904     {
05905     case 7U:
05906       /* in this case, the only change is that we have to pay for this edge in
05907        * Delta(T) */
05908       (*move_val) += weight[e_id];
05909       break;
05910     case 1U:
05911       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF, save 
05912        * one E(B:Bc) and flip BF */
05913       (*move_val) += weight[e_id];
05914       if (edgeData[e_id].num.in_AF)
05915         (*move_val) -= 2 * weight[e_id];
05916       if (edgeData[e_id].num.in_BF)
05917         (*move_val) -= 2 * weight[e_id];
05918       break;
05919     case 3U:
05920       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
05921       if (edgeData[e_id].num.in_BF)
05922         (*move_val) -= weight[e_id];
05923       else
05924         (*move_val) += weight[e_id];
05925       break;
05926     case 5U:
05927       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
05928       if (edgeData[e_id].num.in_AF)
05929         (*move_val) -= weight[e_id];
05930       else
05931         (*move_val) += weight[e_id];
05932       break;
05933     case 0U:
05934       /* in this case we save one Delta(T) */
05935       (*move_val) -= weight[e_id];
05936       break;
05937     default:
05938       EXIT (1, "This should not happen, value %u", pos);
05939     }                           /* end switch */
05940   }                             /* end loop through all incident edges */
05941   return 0;
05942 }
05943 
05944 /* ========================================================================= */
05946 /* ========================================================================= */
05947 static inline int KPTpriceTcAcBc (const KPTMove_t * const cur_move,
05948                                   double *const move_val)
05949 {
05950   /* local variables */
05951   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
05952   unsigned int e_id,
05953     no_id,
05954     pos;
05955 
05956   /* we have to compute every move */
05957   for (; e_it; e_it = e_it->next)
05958   {
05959     e_id = KPTgetEdgeId (e_it);
05960     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
05961     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
05962       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
05963       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
05964     switch (pos)
05965     {
05966     case 0U:
05967       /* in this case, the only change is that we have to pay for this edge in
05968        * Delta(T) */
05969       (*move_val) += weight[e_id];
05970       break;
05971     case 7U:
05972       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
05973        * one E(B:Bc) and flip BF */
05974       (*move_val) -= weight[e_id];
05975       if (!edgeData[e_id].num.in_AF)
05976         (*move_val) += 2 * weight[e_id];
05977       if (!edgeData[e_id].num.in_BF)
05978         (*move_val) += 2 * weight[e_id];
05979       break;
05980     case 5U:
05981       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
05982       if (edgeData[e_id].num.in_BF)
05983         (*move_val) -= weight[e_id];
05984       else
05985         (*move_val) += weight[e_id];
05986       break;
05987     case 3U:
05988       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
05989       if (edgeData[e_id].num.in_AF)
05990         (*move_val) -= weight[e_id];
05991       else
05992         (*move_val) += weight[e_id];
05993       break;
05994     case 1U:
05995       /* in this case we save one Delta(T) */
05996       (*move_val) -= weight[e_id];
05997       break;
05998     default:
05999       EXIT (1, "This should not happen, value %u", pos);
06000     }                           /* end switch */
06001   }                             /* end loop through all incident edges */
06002   return 0;
06003 }
06004 
06005 /* ========================================================================= */
06007 /* ========================================================================= */
06008 static inline int KPTpriceTcABc (const KPTMove_t * const cur_move,
06009                                  double *const move_val)
06010 {
06011   /* local variables */
06012   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
06013   unsigned int e_id,
06014     no_id,
06015     pos;
06016 
06017   /* we have to compute every move */
06018   for (; e_it; e_it = e_it->next)
06019   {
06020     e_id = KPTgetEdgeId (e_it);
06021     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
06022     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
06023       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
06024       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
06025     switch (pos)
06026     {
06027     case 0U:
06028       /* in this case, the only change is that we have to pay for this edge in
06029        * Delta(T) */
06030       (*move_val) += weight[e_id];
06031       break;
06032     case 5U:
06033       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
06034        * one E(B:Bc) and flip BF */
06035       (*move_val) -= weight[e_id];
06036       if (!edgeData[e_id].num.in_AF)
06037         (*move_val) += 2 * weight[e_id];
06038       if (!edgeData[e_id].num.in_BF)
06039         (*move_val) += 2 * weight[e_id];
06040       break;
06041     case 7U:
06042       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
06043       if (edgeData[e_id].num.in_BF)
06044         (*move_val) -= weight[e_id];
06045       else
06046         (*move_val) += weight[e_id];
06047       break;
06048     case 1U:
06049       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
06050       if (edgeData[e_id].num.in_AF)
06051         (*move_val) -= weight[e_id];
06052       else
06053         (*move_val) += weight[e_id];
06054       break;
06055     case 3U:
06056       /* in this case we save one Delta(T) */
06057       (*move_val) -= weight[e_id];
06058       break;
06059     default:
06060       EXIT (1, "This should not happen, value %u", pos);
06061     }                           /* end switch */
06062   }                             /* end loop through all incident edges */
06063   return 0;
06064 }
06065 
06066 /* ========================================================================= */
06068 /* ========================================================================= */
06069 static inline int KPTpriceTcAcB (const KPTMove_t * const cur_move,
06070                                  double *const move_val)
06071 {
06072   /* local variables */
06073   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
06074   unsigned int e_id,
06075     no_id,
06076     pos;
06077 
06078   /* we have to compute every move */
06079   for (; e_it; e_it = e_it->next)
06080   {
06081     e_id = KPTgetEdgeId (e_it);
06082     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
06083     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
06084       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
06085       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
06086     switch (pos)
06087     {
06088     case 0U:
06089       /* in this case, the only change is that we have to pay for this edge in
06090        * Delta(T) */
06091       (*move_val) += weight[e_id];
06092       break;
06093     case 3U:
06094       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
06095        * one E(B:Bc) and flip BF */
06096       (*move_val) -= weight[e_id];
06097       if (!edgeData[e_id].num.in_AF)
06098         (*move_val) += 2 * weight[e_id];
06099       if (!edgeData[e_id].num.in_BF)
06100         (*move_val) += 2 * weight[e_id];
06101       break;
06102     case 1U:
06103       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
06104       if (edgeData[e_id].num.in_BF)
06105         (*move_val) -= weight[e_id];
06106       else
06107         (*move_val) += weight[e_id];
06108       break;
06109     case 7U:
06110       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
06111       if (edgeData[e_id].num.in_AF)
06112         (*move_val) -= weight[e_id];
06113       else
06114         (*move_val) += weight[e_id];
06115       break;
06116     case 5U:
06117       /* in this case we save one Delta(T) */
06118       (*move_val) -= weight[e_id];
06119       break;
06120     default:
06121       EXIT (1, "This should not happen, value %u", pos);
06122     }                           /* end switch */
06123   }                             /* end loop through all incident edges */
06124   return 0;
06125 }
06126 
06127 /* ========================================================================= */
06129 /* ========================================================================= */
06130 static inline int KPTpriceTcAB (const KPTMove_t * const cur_move,
06131                                 double *const move_val)
06132 {
06133   /* local variables */
06134   EGlistNode_t *e_it = all_nodes[cur_move->n_id]->edges->begin;
06135   unsigned int e_id,
06136     no_id,
06137     pos;
06138 
06139   /* we have to compute every move */
06140   for (; e_it; e_it = e_it->next)
06141   {
06142     e_id = KPTgetEdgeId (e_it);
06143     no_id = KPTgetOtherEndId (cur_move->n_id, e_it);
06144     pos = (EGbitTest (nodeData[no_id].It, cur_move->dom) ? 1U : 0U) |
06145       (EGbitTest (nodeData[no_id].Ia, cur_move->dom) ? 2U : 0U) |
06146       (EGbitTest (nodeData[no_id].Ib, cur_move->dom) ? 4U : 0U);
06147     switch (pos)
06148     {
06149     case 0U:
06150       /* in this case, the only change is that we have to pay for this edge in
06151        * Delta(T) */
06152       (*move_val) += weight[e_id];
06153       break;
06154     case 1U:
06155       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF, pay 
06156        * one E(B:Bc) and flip BF */
06157       (*move_val) -= weight[e_id];
06158       if (!edgeData[e_id].num.in_AF)
06159         (*move_val) += 2 * weight[e_id];
06160       if (!edgeData[e_id].num.in_BF)
06161         (*move_val) += 2 * weight[e_id];
06162       break;
06163     case 3U:
06164       /* in this case we save one Delta(T), pay one E(B:Bc) and flip BF */
06165       if (edgeData[e_id].num.in_BF)
06166         (*move_val) -= weight[e_id];
06167       else
06168         (*move_val) += weight[e_id];
06169       break;
06170     case 5U:
06171       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
06172       if (edgeData[e_id].num.in_AF)
06173         (*move_val) -= weight[e_id];
06174       else
06175         (*move_val) += weight[e_id];
06176       break;
06177     case 7U:
06178       /* in this case we save one Delta(T) */
06179       (*move_val) -= weight[e_id];
06180       break;
06181     default:
06182       EXIT (1, "This should not happen, value %u", pos);
06183     }                           /* end switch */
06184   }                             /* end loop through all incident edges */
06185   return 0;
06186 }
06187 
06188 /* ========================================================================= */
06190 /* ========================================================================= */
06191 static inline int KPTpriceTcBc (const KPTMove_t * const cur_move,
06192                                 double *const move_val)
06193 {
06194   /* local variables */
06195   unsigned int e_id,
06196     no_id,
06197     pos,
06198     n_id = cur_move->n_id,
06199     dom = cur_move->dom;
06200   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06201 
06202   /* we have to compute every move */
06203   for (; e_it; e_it = e_it->next)
06204   {
06205     e_id = KPTgetEdgeId (e_it);
06206     no_id = KPTgetOtherEndId (n_id, e_it);
06207     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06208       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
06209     switch (pos)
06210     {
06211     case 0U:
06212       /* in this case, the only change is that we have to pay for this edge in
06213        * Delta(T) */
06214       (*move_val) += weight[e_id];
06215       break;
06216     case 3U:
06217       /* in this case we save one Delta(T), pay one E(B:Bc) and flip AF */
06218       (*move_val) -= weight[e_id];
06219       if (!edgeData[e_id].num.in_BF)
06220         (*move_val) += 2 * weight[e_id];
06221       break;
06222     case 1U:
06223       /* in this case we save one Delta(T) */
06224       (*move_val) -= weight[e_id];
06225       break;
06226     default:
06227       EXIT (1, "This should not happen, value %u", pos);
06228     }                           /* end switch */
06229   }                             /* end loop through all incident edges */
06230   return 0;
06231 }
06232 
06233 /* ========================================================================= */
06235 /* ========================================================================= */
06236 static inline int KPTpriceTcB (const KPTMove_t * const cur_move,
06237                                double *const move_val)
06238 {
06239   /* local variables */
06240   unsigned int e_id,
06241     no_id,
06242     pos,
06243     n_id = cur_move->n_id,
06244     dom = cur_move->dom;
06245   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06246 
06247   /* we have to compute every move */
06248   for (; e_it; e_it = e_it->next)
06249   {
06250     e_id = KPTgetEdgeId (e_it);
06251     no_id = KPTgetOtherEndId (n_id, e_it);
06252     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06253       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
06254     switch (pos)
06255     {
06256     case 0U:
06257       /* in this case, the only change is that we have to pay for this edge in
06258        * Delta(T) */
06259       (*move_val) += weight[e_id];
06260       break;
06261     case 1U:
06262       /* in this case we save one Delta(T), pay one E(B:Bc) and flip AF */
06263       (*move_val) -= weight[e_id];
06264       if (!edgeData[e_id].num.in_BF)
06265         (*move_val) += 2 * weight[e_id];
06266       break;
06267     case 3U:
06268       /* in this case we save one Delta(T) */
06269       (*move_val) -= weight[e_id];
06270       break;
06271     default:
06272       EXIT (1, "This should not happen, value %u", pos);
06273     }                           /* end switch */
06274   }                             /* end loop through all incident edges */
06275   return 0;
06276 }
06277 
06278 /* ========================================================================= */
06280 /* ========================================================================= */
06281 static inline int KPTpriceTcAc (const KPTMove_t * const cur_move,
06282                                 double *const move_val)
06283 {
06284   /* local variables */
06285   unsigned int e_id,
06286     no_id,
06287     pos,
06288     n_id = cur_move->n_id,
06289     dom = cur_move->dom;
06290   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06291 
06292   /* we have to compute every move */
06293   for (; e_it; e_it = e_it->next)
06294   {
06295     e_id = KPTgetEdgeId (e_it);
06296     no_id = KPTgetOtherEndId (n_id, e_it);
06297     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06298       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
06299     switch (pos)
06300     {
06301     case 0U:
06302       /* in this case, the only change is that we have to pay for this edge in
06303        * Delta(T) */
06304       (*move_val) += weight[e_id];
06305       break;
06306     case 3U:
06307       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
06308       (*move_val) -= weight[e_id];
06309       if (!edgeData[e_id].num.in_AF)
06310         (*move_val) += 2 * weight[e_id];
06311       break;
06312     case 1U:
06313       /* in this case we save one Delta(T) */
06314       (*move_val) -= weight[e_id];
06315       break;
06316     default:
06317       EXIT (1, "This should not happen, value %u", pos);
06318     }                           /* end switch */
06319   }                             /* end loop through all incident edges */
06320   return 0;
06321 }
06322 
06323 /* ========================================================================= */
06325 /* ========================================================================= */
06326 static inline int KPTpriceTcA (const KPTMove_t * const cur_move,
06327                                double *const move_val)
06328 {
06329   /* local variables */
06330   unsigned int e_id,
06331     no_id,
06332     pos,
06333     n_id = cur_move->n_id,
06334     dom = cur_move->dom;
06335   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06336 
06337   /* we have to compute every move */
06338   for (; e_it; e_it = e_it->next)
06339   {
06340     e_id = KPTgetEdgeId (e_it);
06341     no_id = KPTgetOtherEndId (n_id, e_it);
06342     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06343       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
06344     switch (pos)
06345     {
06346     case 0U:
06347       /* in this case, the only change is that we have to pay for this edge in
06348        * Delta(T) */
06349       (*move_val) += weight[e_id];
06350       break;
06351     case 1U:
06352       /* in this case we save one Delta(T), pay one E(A:Ac) and flip AF */
06353       (*move_val) -= weight[e_id];
06354       if (!edgeData[e_id].num.in_AF)
06355         (*move_val) += 2 * weight[e_id];
06356       break;
06357     case 3U:
06358       /* in this case we save one Delta(T) */
06359       (*move_val) -= weight[e_id];
06360       break;
06361     default:
06362       EXIT (1, "This should not happen, value %u", pos);
06363     }                           /* end switch */
06364   }                             /* end loop through all incident edges */
06365   return 0;
06366 }
06367 
06368 /* ========================================================================= */
06370 /* ========================================================================= */
06371 static inline int KPTpriceBcTc (const KPTMove_t * const cur_move,
06372                                 double *const move_val)
06373 {
06374   /* local variables */
06375   unsigned int e_id,
06376     no_id,
06377     pos,
06378     n_id = cur_move->n_id,
06379     dom = cur_move->dom;
06380   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06381 
06382   /* we have to compute every move */
06383   for (; e_it; e_it = e_it->next)
06384   {
06385     e_id = KPTgetEdgeId (e_it);
06386     no_id = KPTgetOtherEndId (n_id, e_it);
06387     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06388       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
06389     switch (pos)
06390     {
06391     case 0U:
06392       /* in this case, the only change is that we have to save for this edge in
06393        * Delta(T) */
06394       (*move_val) -= weight[e_id];
06395       break;
06396     case 3U:
06397       /* in this case we pay one Delta(T), save one E(B:Bc) and flip BF */
06398       (*move_val) += weight[e_id];
06399       if (edgeData[e_id].num.in_BF)
06400         (*move_val) -= 2 * weight[e_id];
06401       break;
06402     case 1U:
06403       /* in this case we pay one Delta(T) */
06404       (*move_val) += weight[e_id];
06405       break;
06406     default:
06407       EXIT (1, "This should not happen, value %u", pos);
06408     }                           /* end switch */
06409   }                             /* end loop through all incident edges */
06410   return 0;
06411 }
06412 
06413 /* ========================================================================= */
06415 /* ========================================================================= */
06416 static inline int KPTpriceBTc (const KPTMove_t * const cur_move,
06417                                double *const move_val)
06418 {
06419   /* local variables */
06420   unsigned int e_id,
06421     no_id,
06422     pos,
06423     n_id = cur_move->n_id,
06424     dom = cur_move->dom;
06425   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06426 
06427   /* we have to compute every move */
06428   for (; e_it; e_it = e_it->next)
06429   {
06430     e_id = KPTgetEdgeId (e_it);
06431     no_id = KPTgetOtherEndId (n_id, e_it);
06432     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06433       (EGbitTest (nodeData[no_id].Ib, dom) ? 2U : 0U);
06434     switch (pos)
06435     {
06436     case 0U:
06437       /* in this case, the only change is that we have to save for this edge in
06438        * Delta(T) */
06439       (*move_val) -= weight[e_id];
06440       break;
06441     case 1U:
06442       /* in this case we pay one Delta(T), save one E(B:Bc) and flip AF */
06443       (*move_val) += weight[e_id];
06444       if (edgeData[e_id].num.in_BF)
06445         (*move_val) -= 2 * weight[e_id];
06446       break;
06447     case 3U:
06448       /* in this case we pay one Delta(T) */
06449       (*move_val) += weight[e_id];
06450       break;
06451     default:
06452       EXIT (1, "This should not happen, value %u", pos);
06453     }                           /* end switch */
06454   }                             /* end loop through all incident edges */
06455   return 0;
06456 }
06457 
06458 /* ========================================================================= */
06460 /* ========================================================================= */
06461 static inline int KPTpriceAcTc (const KPTMove_t * const cur_move,
06462                                 double *const move_val)
06463 {
06464   /* local variables */
06465   unsigned int e_id,
06466     no_id,
06467     pos,
06468     n_id = cur_move->n_id,
06469     dom = cur_move->dom;
06470   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06471 
06472   /* we have to compute every move */
06473   for (; e_it; e_it = e_it->next)
06474   {
06475     e_id = KPTgetEdgeId (e_it);
06476     no_id = KPTgetOtherEndId (n_id, e_it);
06477     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06478       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
06479     switch (pos)
06480     {
06481     case 0U:
06482       /* in this case, the only change is that we have to save for this edge in
06483        * Delta(T) */
06484       (*move_val) -= weight[e_id];
06485       break;
06486     case 3U:
06487       /* in this case we save one Delta(T), save one E(A:Ac) and flip AF */
06488       (*move_val) += weight[e_id];
06489       if (edgeData[e_id].num.in_AF)
06490         (*move_val) -= 2 * weight[e_id];
06491       break;
06492     case 1U:
06493       /* in this case we save one Delta(T) */
06494       (*move_val) += weight[e_id];
06495       break;
06496     default:
06497       EXIT (1, "This should not happen, value %u", pos);
06498     }                           /* end switch */
06499   }                             /* end loop through all incident edges */
06500   return 0;
06501 }
06502 
06503 /* ========================================================================= */
06505 /* ========================================================================= */
06506 static inline int KPTpriceATc (const KPTMove_t * const cur_move,
06507                                double *const move_val)
06508 {
06509   /* local variables */
06510   unsigned int e_id,
06511     no_id,
06512     pos,
06513     n_id = cur_move->n_id,
06514     dom = cur_move->dom;
06515   EGlistNode_t *e_it = all_nodes[n_id]->edges->begin;
06516 
06517   /* we have to compute every move */
06518   for (; e_it; e_it = e_it->next)
06519   {
06520     e_id = KPTgetEdgeId (e_it);
06521     no_id = KPTgetOtherEndId (n_id, e_it);
06522     pos = (EGbitTest (nodeData[no_id].It, dom) ? 1U : 0U) |
06523       (EGbitTest (nodeData[no_id].Ia, dom) ? 2U : 0U);
06524     switch (pos)
06525     {
06526     case 0U:
06527       /* in this case, the only change is that we have to save for this edge in
06528        * Delta(T) */
06529       (*move_val) -= weight[e_id];
06530       break;
06531     case 1U:
06532       /* in this case we pay one Delta(T), save one E(A:Ac) and flip AF */
06533       (*move_val) += weight[e_id];
06534       if (edgeData[e_id].num.in_AF)
06535         (*move_val) -= 2 * weight[e_id];
06536       break;
06537     case 3U:
06538       /* in this case we pay one Delta(T) */
06539       (*move_val) += weight[e_id];
06540       break;
06541     default:
06542       EXIT (1, "This should not happen, value %u", pos);
06543     }                           /* end switch */
06544   }                             /* end loop through all incident edges */
06545   return 0;
06546 }
06547 
06548 /* ========================================================================= */
06550 /* ========================================================================= */
06551 static inline int KPTmakeFullMove (KPTFullMove_t const *const full_move)
06552 {
06553   unsigned int depth = 0;
06554   for (; depth < full_move->depth; depth++)
06555     KPTmakeMove (full_move->move + depth, 1);
06556   return 0;
06557 }
06558 
06559 /* ========================================================================= */
06561 /* ========================================================================= */
06562 #define KPTgoDeeper(__depth) if(__depth+1<KPT_MAX_DEPTH){\
06563   /* now we call deeper moves */\
06564   KPTmakeMove(base_move->move+__depth,0);\
06565   for( e_it = all_nodes[nc_id]->edges->begin; e_it ; e_it=e_it->next){\
06566     /*if(KPTgetOtherEndId(nc_id,e_it)<nc_id)*/\
06567     KPTSetBestMove( KPTgetOtherEndId( nc_id, e_it), best_move, \
06568                     base_move, __depth + 1);}\
06569   /* undo the last move */\
06570   KPTmakeInvMove(base_move->move+__depth,0);\
06571   }
06572 
06573 
06574 /* ========================================================================= */
06581 /* ========================================================================= */
06582 static int KPTSetBestMove (const unsigned int nc_id,
06583                            KPTFullMove_t * const best_move,
06584                            KPTFullMove_t * const base_move,
06585                            const unsigned int depth)
06586 {
06587   /* local variables */
06588   unsigned nc_inA,
06589     nc_inB,
06590     nc_inTc;
06591   KPTMove_t *c_movep = base_move->move + depth;
06592   unsigned type,
06593     pos,
06594     nc_inAdB,
06595    *domp = &(c_movep->dom);
06596   const double move_val = base_move->val;
06597   EGlistNode_t *e_it;
06598   MESSAGE (KPT_VRB + 19, "entering depth %u", depth);
06599   TESTL (KPT_EDBG, nc_id > graphData.n_nodes,
06600          "nc_id %u out of range (n_nodes %u)", nc_id, graphData.n_nodes);
06601   /* check that the depth is OK, if no, we return back */
06602   if (depth >= KPT_MAX_DEPTH)
06603     return 0;
06604   /* basic set-up */
06605   c_movep->n_id = nc_id;
06606   c_movep->move_id = KPT_no_move;
06607   base_move->depth = depth + 1;
06608   /* now we check the adding moves if they can be considered */
06609   (*domp) = graphData.n_dominos;
06610   for (; (*domp)--;)
06611   {
06612     nc_inA = EGbitTest (nodeData[nc_id].Ia, (*domp)) ? 1U : 0U;
06613     nc_inB = EGbitTest (nodeData[nc_id].Ib, (*domp)) ? 1U : 0U;
06614     nc_inTc = EGbitTest (nodeData[nc_id].It, (*domp)) ? 0U : 1U;
06615     type = (EGbitTest (graphData.A_partition, (*domp)) ? 1U : 0U) |
06616       (EGbitTest (graphData.B_partition, (*domp)) ? 2U : 0U);
06617     /* first check addind moves, but only if they have not been done */
06618     if (nc_inTc && !EGbitTest (nodeData[nc_id].added, (*domp)) &&
06619         (graphData.n_Tc[(*domp)] > 1))
06620     {
06621       switch (type)
06622       {
06623       case 1U:
06624         /* ----------------------------------------------------------------- */
06625         /* Check KPT_Tc_Ac */
06626         base_move->val = move_val;
06627         c_movep->move_id = KPT_Tc_Ac;
06628         KPTpriceTcAc (c_movep, &(base_move->val));
06629         KPTupdateMove (base_move, best_move);
06630         /* now we call deeper moves */
06631         KPTgoDeeper (depth);
06632         /* ----------------------------------------------------------------- */
06633         /* Check KPT_Tc_A */
06634         base_move->val = move_val;
06635         c_movep->move_id = KPT_Tc_A;
06636         KPTpriceTcA (c_movep, &(base_move->val));
06637         KPTupdateMove (base_move, best_move);
06638         /* now we call deeper moves */
06639         KPTgoDeeper (depth);
06640         break;
06641       case 2U:
06642         /* ----------------------------------------------------------------- */
06643         /* Check KPT_Tc_B */
06644         base_move->val = move_val;
06645         c_movep->move_id = KPT_Tc_B;
06646         KPTpriceTcB (c_movep, &(base_move->val));
06647         KPTupdateMove (base_move, best_move);
06648         /* now we call deeper moves */
06649         KPTgoDeeper (depth);
06650         /* ----------------------------------------------------------------- */
06651         /* Check KPT_Tc_Bc */
06652         base_move->val = move_val;
06653         c_movep->move_id = KPT_Tc_Bc;
06654         KPTpriceTcBc (c_movep, &(base_move->val));
06655         KPTupdateMove (base_move, best_move);
06656         /* now we call deeper moves */
06657         KPTgoDeeper (depth);
06658         break;
06659       case 3U:
06660         /* ----------------------------------------------------------------- */
06661         /* Check KPT_Tc_AB */
06662         base_move->val = move_val;
06663         c_movep->move_id = KPT_Tc_AB;
06664         KPTpriceTcAB (c_movep, &(base_move->val));
06665         KPTupdateMove (base_move, best_move);
06666         /* now we call deeper moves */
06667         KPTgoDeeper (depth);
06668         /* ----------------------------------------------------------------- */
06669         /* Check KPT_Tc_AcB */
06670         base_move->val = move_val;
06671         c_movep->move_id = KPT_Tc_AcB;
06672         KPTpriceTcAcB (c_movep, &(base_move->val));
06673         KPTupdateMove (base_move, best_move);
06674         /* now we call deeper moves */
06675         KPTgoDeeper (depth);
06676         /* ----------------------------------------------------------------- */
06677         /* Check KPT_Tc_ABc */
06678         base_move->val = move_val;
06679         c_movep->move_id = KPT_Tc_ABc;
06680         KPTpriceTcABc (c_movep, &(base_move->val));
06681         KPTupdateMove (base_move, best_move);
06682         /* now we call deeper moves */
06683         KPTgoDeeper (depth);
06684         /* ----------------------------------------------------------------- */
06685         /* Check KPT_Tc_AcBc */
06686         base_move->val = move_val;
06687         c_movep->move_id = KPT_Tc_AcBc;
06688         KPTpriceTcAcBc (c_movep, &(base_move->val));
06689         KPTupdateMove (base_move, best_move);
06690         /* now we call deeper moves */
06691         KPTgoDeeper (depth);
06692         break;
06693       default:
06694         EXIT (1, "domino type %u unknown", type);
06695         /* ----------------------------------------------------------------- */
06696       }                         /* end checking adding moves */
06697     }                           /* end switch */
06698   }                             /* end loop through all dominos */
06699   /* now we check if this node can be added to the handle */
06700   type = ((!nodeData[nc_id].in_BH && !nodeData[nc_id].added_BH &&
06701            (graphData.n_BH[0] > 1)) ? 2U : 0U) | ((!nodeData[nc_id].in_AH &&
06702                                                    !nodeData[nc_id].added_AH
06703                                                    && (graphData.n_AH[0] >
06704                                                        1)) ? 1U : 0U);
06705   switch (type)
06706   {
06707   case 3U:
06708   case 1U:
06709     /* --------------------------------------------------------------------- */
06710     /* Check KPT_AHc_AH */
06711     base_move->val = move_val;
06712     c_movep->move_id = KPT_AHc_AH;
06713     KPTpriceAHcAH (c_movep, &(base_move->val));
06714     KPTupdateMove (base_move, best_move);
06715     /* now we call deeper moves */
06716     KPTgoDeeper (depth);
06717     if (type == 1U)
06718       break;
06719   case 2U:
06720     /* --------------------------------------------------------------------- */
06721     /* Check KPT_BHc_BH */
06722     base_move->val = move_val;
06723     c_movep->move_id = KPT_BHc_BH;
06724     KPTpriceBHcBH (c_movep, &(base_move->val));
06725     KPTupdateMove (base_move, best_move);
06726     /* now we call deeper moves */
06727     KPTgoDeeper (depth);
06728     if (type == 2U)
06729       break;
06730     /* --------------------------------------------------------------------- */
06731     /* Check KPT_AHc_AH_BHc_BH */
06732     base_move->val = move_val;
06733     c_movep->move_id = KPT_AHc_AH_BHc_BH;
06734     KPTpriceAHcAHBHcBH (c_movep, &(base_move->val));
06735     KPTupdateMove (base_move, best_move);
06736     /* now we call deeper moves */
06737     KPTgoDeeper (depth);
06738     break;
06739   case 0:
06740     break;
06741     /* --------------------------------------------------------------------- */
06742   default:
06743     EXIT (1, "Unknown type %u", type);
06744   }
06745   /* now we check moves that flip this node from A to B */
06746   (*domp) = graphData.n_dominos;
06747   for (; (*domp)--;)
06748   {
06749     nc_inA = EGbitTest (nodeData[nc_id].Ia, (*domp)) ? 1U : 0U;
06750     nc_inB = EGbitTest (nodeData[nc_id].Ib, (*domp)) ? 1U : 0U;
06751     nc_inTc = EGbitTest (nodeData[nc_id].It, (*domp)) ? 0U : 1U;
06752     nc_inAdB = EGbitTest (nodeData[nc_id].Iadb, (*domp)) ? 1U : 0U;
06753     type = (EGbitTest (graphData.A_partition, (*domp)) ? 1U : 0U) |
06754       (EGbitTest (graphData.B_partition, (*domp)) ? 2U : 0U);
06755     if (!nc_inTc)
06756     {
06757       switch (type)
06758       {
06759       case 3U:
06760       case 1U:
06761         /* ----------------------------------------------------------------- */
06762         /* check KPT_A_Ac */
06763         if (nc_inA && (graphData.n_A[1][(*domp)] > 1) &&
06764             !EGbitTest (nodeData[nc_id].flipA, (*domp)) &&
06765             (!EGbitTest (graphData.Kdom, (*domp)) ||
06766              (graphData.n_AdB[nc_inAdB][(*domp)] > 1)))
06767         {
06768           base_move->val = move_val;
06769           c_movep->move_id = KPT_A_Ac;
06770           KPTpriceAAc (c_movep, &(base_move->val));
06771           KPTupdateMove (base_move, best_move);
06772           /* now we call deeper moves */
06773           KPTgoDeeper (depth);
06774           /* ----------------------------------------------------------------- */
06775           /* check KPT_A_Ac_flipAH */
06776           if (graphData.n_AH[nodeData[nc_id].in_AH] > 1)
06777           {
06778             base_move->val = move_val;
06779             c_movep->move_id = KPT_A_Ac_flipAH;
06780             KPTpriceAAcflipAH (c_movep, &(base_move->val));
06781             KPTupdateMove (base_move, best_move);
06782             /* now we call deeper moves */
06783             KPTgoDeeper (depth);
06784           }
06785         }
06786         /* ----------------------------------------------------------------- */
06787         /* check KPT_Ac_A */
06788         else if (!nc_inA && (graphData.n_A[0][(*domp)] > 1) &&
06789                  !EGbitTest (nodeData[nc_id].flipAc, (*domp)) &&
06790                  (!EGbitTest (graphData.Kdom, (*domp)) ||
06791                   (graphData.n_AdB[nc_inAdB][(*domp)] > 1)))
06792         {
06793           base_move->val = move_val;
06794           c_movep->move_id = KPT_Ac_A;
06795           KPTpriceAcA (c_movep, &(base_move->val));
06796           KPTupdateMove (base_move, best_move);
06797           /* now we call deeper moves */
06798           KPTgoDeeper (depth);
06799           /* ----------------------------------------------------------------- */
06800           /* check KPT_Ac_A_flipH */
06801           if (graphData.n_AH[nodeData[nc_id].in_AH] > 1)
06802           {
06803             base_move->val = move_val;
06804             c_movep->move_id = KPT_Ac_A_flipAH;
06805             KPTpriceAcAflipAH (c_movep, &(base_move->val));
06806             KPTupdateMove (base_move, best_move);
06807             /* now we call deeper moves */
06808             KPTgoDeeper (depth);
06809           }
06810         }
06811         /* ----------------------------------------------------------------- */
06812         if (type == 1U)
06813           break;
06814       case 2U:
06815         /* ----------------------------------------------------------------- */
06816         /* check KPT_B_Bc */
06817         if (nc_inB && (graphData.n_B[1][(*domp)] > 1) &&
06818             !EGbitTest (nodeData[nc_id].flipB, (*domp)) &&
06819             (!EGbitTest (graphData.Kdom, (*domp)) ||
06820              (graphData.n_AdB[nc_inAdB][(*domp)] > 1)))
06821         {
06822           base_move->val = move_val;
06823           c_movep->move_id = KPT_B_Bc;
06824           KPTpriceBBc (c_movep, &(base_move->val));
06825           KPTupdateMove (base_move, best_move);
06826           /* now we call deeper moves */
06827           KPTgoDeeper (depth);
06828           /* ----------------------------------------------------------------- */
06829           /* check KPT_B_Bc_flipBH */
06830           if (graphData.n_BH[nodeData[nc_id].in_BH] > 1)
06831           {
06832             base_move->val = move_val;
06833             c_movep->move_id = KPT_B_Bc_flipBH;
06834             KPTpriceBBcflipBH (c_movep, &(base_move->val));
06835             KPTupdateMove (base_move, best_move);
06836             /* now we call deeper moves */
06837             KPTgoDeeper (depth);
06838           }
06839         }
06840         /* ----------------------------------------------------------------- */
06841         /* check KPT_Bc_B */
06842         else if (!nc_inB && (graphData.n_B[0][(*domp)] > 1) &&
06843                  !EGbitTest (nodeData[nc_id].flipBc, (*domp)) &&
06844                  (!EGbitTest (graphData.Kdom, (*domp)) ||
06845                   (graphData.n_AdB[nc_inAdB][(*domp)] > 1)))
06846         {
06847           base_move->val = move_val;
06848           c_movep->move_id = KPT_Bc_B;
06849           KPTpriceBcB (c_movep, &(base_move->val));
06850           KPTupdateMove (base_move, best_move);
06851           /* now we call deeper moves */
06852           KPTgoDeeper (depth);
06853           /* ----------------------------------------------------------------- */
06854           /* check KPT_Bc_B_flipH */
06855           if (graphData.n_BH[nodeData[nc_id].in_BH] > 1)
06856           {
06857             base_move->val = move_val;
06858             c_movep->move_id = KPT_Bc_B_flipBH;
06859             KPTpriceBcBflipBH (c_movep, &(base_move->val));
06860             KPTupdateMove (base_move, best_move);
06861             /* now we call deeper moves */
06862             KPTgoDeeper (depth);
06863           }
06864         }
06865         /* ----------------------------------------------------------------- */
06866         if (type == 2U)
06867           break;
06868         /* ----------------------------------------------------------------- */
06869         /* check KPT_A_Ac_B_Bc */
06870         if (nc_inA && (graphData.n_A[1][(*domp)] > 1) &&
06871             !EGbitTest (nodeData[nc_id].flipA, (*domp)) &&
06872             nc_inB && (graphData.n_B[1][(*domp)] > 1) &&
06873             !EGbitTest (nodeData[nc_id].flipB, (*domp)))
06874         {
06875           base_move->val = move_val;
06876           c_movep->move_id = KPT_A_Ac_B_Bc;
06877           KPTpriceAAcBBc (c_movep, &(base_move->val));
06878           KPTupdateMove (base_move, best_move);
06879           /* now we call deeper moves */
06880           KPTgoDeeper (depth);
06881           /* ----------------------------------------------------------------- */
06882           /* check KPT_A_Ac_B_Bc_flipAH */
06883           if ((graphData.n_AH[nodeData[nc_id].in_AH] > 1))
06884           {
06885             base_move->val = move_val;
06886             c_movep->move_id = KPT_A_Ac_B_Bc_flipAH;
06887             KPTpriceAAcBBcAH (c_movep, &(base_move->val));
06888             KPTupdateMove (base_move, best_move);
06889             /* now we call deeper moves */
06890             KPTgoDeeper (depth);
06891           }
06892           /* ----------------------------------------------------------------- */
06893           /* check KPT_A_Ac_B_Bc_flipBH */
06894           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1))
06895           {
06896             base_move->val = move_val;
06897             c_movep->move_id = KPT_A_Ac_B_Bc_flipBH;
06898             KPTpriceAAcBBcBH (c_movep, &(base_move->val));
06899             KPTupdateMove (base_move, best_move);
06900             /* now we call deeper moves */
06901             KPTgoDeeper (depth);
06902           }
06903           /* ----------------------------------------------------------------- */
06904           /* check KPT_A_Ac_B_Bc_flipAHBH */
06905           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1) &&
06906               (graphData.n_AH[nodeData[nc_id].in_AH] > 1))
06907           {
06908             base_move->val = move_val;
06909             c_movep->move_id = KPT_A_Ac_B_Bc_flipAHBH;
06910             KPTpriceAAcBBcAHBH (c_movep, &(base_move->val));
06911             KPTupdateMove (base_move, best_move);
06912             /* now we call deeper moves */
06913             KPTgoDeeper (depth);
06914           }
06915         }
06916         /* ----------------------------------------------------------------- */
06917         /* check KPT_Ac_A_B_Bc */
06918         else if (!nc_inA && (graphData.n_A[0][(*domp)] > 1) &&
06919                  !EGbitTest (nodeData[nc_id].flipAc, (*domp)) &&
06920                  nc_inB && (graphData.n_B[1][(*domp)] > 1) &&
06921                  !EGbitTest (nodeData[nc_id].flipB, (*domp)))
06922         {
06923           base_move->val = move_val;
06924           c_movep->move_id = KPT_Ac_A_B_Bc;
06925           KPTpriceAcABBc (c_movep, &(base_move->val));
06926           KPTupdateMove (base_move, best_move);
06927           /* now we call deeper moves */
06928           KPTgoDeeper (depth);
06929           /* ----------------------------------------------------------------- */
06930           /* check KPT_Ac_A_B_Bc_flipAH */
06931           if ((graphData.n_AH[nodeData[nc_id].in_AH] > 1))
06932           {
06933             base_move->val = move_val;
06934             c_movep->move_id = KPT_Ac_A_B_Bc_flipAH;
06935             KPTpriceAcABBcAH (c_movep, &(base_move->val));
06936             KPTupdateMove (base_move, best_move);
06937             /* now we call deeper moves */
06938             KPTgoDeeper (depth);
06939           }
06940           /* ----------------------------------------------------------------- */
06941           /* check KPT_Ac_A_B_Bc_flipBH */
06942           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1))
06943           {
06944             base_move->val = move_val;
06945             c_movep->move_id = KPT_Ac_A_B_Bc_flipBH;
06946             KPTpriceAcABBcBH (c_movep, &(base_move->val));
06947             KPTupdateMove (base_move, best_move);
06948             /* now we call deeper moves */
06949             KPTgoDeeper (depth);
06950           }
06951           /* ----------------------------------------------------------------- */
06952           /* check KPT_Ac_A_B_Bc_flipAHBH */
06953           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1) &&
06954               (graphData.n_AH[nodeData[nc_id].in_AH] > 1))
06955           {
06956             base_move->val = move_val;
06957             c_movep->move_id = KPT_Ac_A_B_Bc_flipAHBH;
06958             KPTpriceAcABBcAHBH (c_movep, &(base_move->val));
06959             KPTupdateMove (base_move, best_move);
06960             /* now we call deeper moves */
06961             KPTgoDeeper (depth);
06962           }
06963         }
06964         /* ----------------------------------------------------------------- */
06965         /* check KPT_A_Ac_Bc_B */
06966         else if (nc_inA && (graphData.n_A[1][(*domp)] > 1) &&
06967                  !EGbitTest (nodeData[nc_id].flipA, (*domp)) &&
06968                  !nc_inB && (graphData.n_B[0][(*domp)] > 1) &&
06969                  !EGbitTest (nodeData[nc_id].flipBc, (*domp)))
06970         {
06971           base_move->val = move_val;
06972           c_movep->move_id = KPT_A_Ac_Bc_B;
06973           KPTpriceAAcBcB (c_movep, &(base_move->val));
06974           KPTupdateMove (base_move, best_move);
06975           /* now we call deeper moves */
06976           KPTgoDeeper (depth);
06977           /* ----------------------------------------------------------------- */
06978           /* check KPT_A_Ac_Bc_B_flipAH */
06979           if ((graphData.n_AH[nodeData[nc_id].in_AH] > 1))
06980           {
06981             base_move->val = move_val;
06982             c_movep->move_id = KPT_A_Ac_Bc_B_flipAH;
06983             KPTpriceAAcBcBAH (c_movep, &(base_move->val));
06984             KPTupdateMove (base_move, best_move);
06985             /* now we call deeper moves */
06986             KPTgoDeeper (depth);
06987           }
06988           /* ----------------------------------------------------------------- */
06989           /* check KPT_A_Ac_Bc_B_flipBH */
06990           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1))
06991           {
06992             base_move->val = move_val;
06993             c_movep->move_id = KPT_A_Ac_Bc_B_flipBH;
06994             KPTpriceAAcBcBBH (c_movep, &(base_move->val));
06995             KPTupdateMove (base_move, best_move);
06996             /* now we call deeper moves */
06997             KPTgoDeeper (depth);
06998           }
06999           /* ----------------------------------------------------------------- */
07000           /* check KPT_A_Ac_Bc_B_flipAHBH */
07001           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1) &&
07002               (graphData.n_AH[nodeData[nc_id].in_AH] > 1))
07003           {
07004             base_move->val = move_val;
07005             c_movep->move_id = KPT_A_Ac_Bc_B_flipAHBH;
07006             KPTpriceAAcBcBAHBH (c_movep, &(base_move->val));
07007             KPTupdateMove (base_move, best_move);
07008             /* now we call deeper moves */
07009             KPTgoDeeper (depth);
07010           }
07011         }
07012         /* ----------------------------------------------------------------- */
07013         /* check KPT_Ac_A_Bc_B */
07014         else if (!nc_inA && (graphData.n_A[0][(*domp)] > 1) &&
07015                  !EGbitTest (nodeData[nc_id].flipAc, (*domp)) &&
07016                  !nc_inB && (graphData.n_B[0][(*domp)] > 1) &&
07017                  !EGbitTest (nodeData[nc_id].flipBc, (*domp)))
07018         {
07019           base_move->val = move_val;
07020           c_movep->move_id = KPT_Ac_A_Bc_B;
07021           KPTpriceAcABcB (c_movep, &(base_move->val));
07022           KPTupdateMove (base_move, best_move);
07023           /* now we call deeper moves */
07024           KPTgoDeeper (depth);
07025           /* ----------------------------------------------------------------- */
07026           /* check KPT_Ac_A_Bc_B_flipAH */
07027           if ((graphData.n_AH[nodeData[nc_id].in_AH] > 1))
07028           {
07029             base_move->val = move_val;
07030             c_movep->move_id = KPT_Ac_A_Bc_B_flipAH;
07031             KPTpriceAcABcBAH (c_movep, &(base_move->val));
07032             KPTupdateMove (base_move, best_move);
07033             /* now we call deeper moves */
07034             KPTgoDeeper (depth);
07035           }
07036           /* ----------------------------------------------------------------- */
07037           /* check KPT_Ac_A_Bc_B_flipBH */
07038           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1))
07039           {
07040             base_move->val = move_val;
07041             c_movep->move_id = KPT_Ac_A_Bc_B_flipBH;
07042             KPTpriceAcABcBBH (c_movep, &(base_move->val));
07043             KPTupdateMove (base_move, best_move);
07044             /* now we call deeper moves */
07045             KPTgoDeeper (depth);
07046           }
07047           /* ----------------------------------------------------------------- */
07048           /* check KPT_Ac_A_Bc_B_flipAHBH */
07049           if ((graphData.n_BH[nodeData[nc_id].in_BH] > 1) &&
07050               (graphData.n_AH[nodeData[nc_id].in_AH] > 1))
07051           {
07052             base_move->val = move_val;
07053             c_movep->move_id = KPT_Ac_A_Bc_B_flipAHBH;
07054             KPTpriceAcABcBAHBH (c_movep, &(base_move->val));
07055             KPTupdateMove (base_move, best_move);
07056             /* now we call deeper moves */
07057             KPTgoDeeper (depth);
07058           }
07059         }
07060         break;
07061       default:
07062         EXIT (1, "Unknown type %u", type);
07063         /* ----------------------------------------------------------------- */
07064       }                         /* end case nc in T */
07065     }                           /* end switch type */
07066   }                             /* end checking non-growing moves for dominos */
07067   /* now we check if this node can shufled between handles */
07068   /* ----------------------------------------------------------------------- */
07069   /* check KPT_AHc_AH_BH_BHc */
07070   if (!nodeData[nc_id].in_AH && (graphData.n_AH[0] > 1) &&
07071       nodeData[nc_id].in_BH && (graphData.n_BH[1] > 1) &&
07072       !nodeData[nc_id].added_AH)
07073   {
07074     base_move->val = move_val;
07075     c_movep->move_id = KPT_AHc_AH_BH_BHc;
07076     KPTpriceAHcAHBHBHc (c_movep, &(base_move->val));
07077     KPTupdateMove (base_move, best_move);
07078     /* now we call deeper moves */
07079     KPTgoDeeper (depth);
07080   }
07081   /* ----------------------------------------------------------------------- */
07082   /* check KPT_AH_AHc_BHc_BH */
07083   if (nodeData[nc_id].in_AH && (graphData.n_AH[1] > 1) &&
07084       !nodeData[nc_id].in_BH && (graphData.n_BH[0] > 1) &&
07085       !nodeData[nc_id].added_BH)
07086   {
07087     base_move->val = move_val;
07088     c_movep->move_id = KPT_AH_AHc_BHc_BH;
07089     KPTpriceAHAHcBHcBH (c_movep, &(base_move->val));
07090     KPTupdateMove (base_move, best_move);
07091     /* now we call deeper moves */
07092     KPTgoDeeper (depth);
07093   }
07094   /* ----------------------------------------------------------------------- */
07095   /* now we check moves that may get this node out of a teeth */
07096   (*domp) = graphData.n_dominos;
07097   for (; (*domp)--;)
07098   {
07099     nc_inA = EGbitTest (nodeData[nc_id].Ia, (*domp)) ? 1U : 0U;
07100     nc_inB = EGbitTest (nodeData[nc_id].Ib, (*domp)) ? 1U : 0U;
07101     nc_inTc = EGbitTest (nodeData[nc_id].It, (*domp)) ? 0U : 1U;
07102     nc_inAdB = EGbitTest (nodeData[nc_id].Iadb, (*domp)) ? 1U : 0U;
07103     type = (EGbitTest (graphData.A_partition, (*domp)) ? 1U : 0U) |
07104       (EGbitTest (graphData.B_partition, (*domp)) ? 2U : 0U);
07105     if (!nc_inTc)
07106     {
07107       switch (type)
07108       {
07109       case 1U:
07110         if (graphData.n_A[nc_inA][(*domp)] > 1)
07111         {
07112           /* --------------------------------------------------------------- */
07113           /* Check KPT_A_Tc */
07114           if (nc_inA)
07115           {
07116             base_move->val = move_val;
07117             c_movep->move_id = KPT_A_Tc;
07118             KPTpriceATc (c_movep, &(base_move->val));
07119             KPTupdateMove (base_move, best_move);
07120             /* now we call deeper moves */
07121             KPTgoDeeper (depth);
07122           }
07123           /* --------------------------------------------------------------- */
07124           /* Check KPT_Ac_Tc */
07125           else
07126           {
07127             base_move->val = move_val;
07128             c_movep->move_id = KPT_Ac_Tc;
07129             KPTpriceAcTc (c_movep, &(base_move->val));
07130             KPTupdateMove (base_move, best_move);
07131             /* now we call deeper moves */
07132             KPTgoDeeper (depth);
07133           }
07134         }                       /*end case a A-domino */
07135         break;
07136       case 2U:
07137         if (graphData.n_B[nc_inB][(*domp)] > 1)
07138         {
07139           /* --------------------------------------------------------------- */
07140           /* Check KPT_B_Tc */
07141           if (nc_inB)
07142           {
07143             base_move->val = move_val;
07144             c_movep->move_id = KPT_B_Tc;
07145             KPTpriceBTc (c_movep, &(base_move->val));
07146             KPTupdateMove (base_move, best_move);
07147             /* now we call deeper moves */
07148             KPTgoDeeper (depth);
07149           }
07150           /* --------------------------------------------------------------- */
07151           /* Check KPT_Bc_Tc */
07152           else
07153           {
07154             base_move->val = move_val;
07155             c_movep->move_id = KPT_Bc_Tc;
07156             KPTpriceBcTc (c_movep, &(base_move->val));
07157             KPTupdateMove (base_move, best_move);
07158             /* now we call deeper moves */
07159             KPTgoDeeper (depth);
07160           }
07161           /* --------------------------------------------------------------- */
07162         }                       /*end case a B-domino */
07163         break;
07164       case 3U:
07165         if ((graphData.n_B[nc_inB][(*domp)] > 1) &&
07166             (graphData.n_A[nc_inA][(*domp)] > 1) &&
07167             (graphData.n_AdB[nc_inAdB][(*domp)] > 1))
07168         {
07169           pos = (nc_inA ? 1U : 0U) | (nc_inB ? 2U : 0U);
07170           switch (pos)
07171           {
07172           case 0:
07173             /* ------------------------------------------------------------- */
07174             /* Check KPT_AcBcTc */
07175             base_move->val = move_val;
07176             c_movep->move_id = KPT_AcBc_Tc;
07177             KPTpriceAcBcTc (c_movep, &(base_move->val));
07178             KPTupdateMove (base_move, best_move);
07179             /* now we call deeper moves */
07180             KPTgoDeeper (depth);
07181             break;
07182           case 1:
07183             /* ------------------------------------------------------------- */
07184             /* Check KPT_ABcTc */
07185             base_move->val = move_val;
07186             c_movep->move_id = KPT_ABc_Tc;
07187             KPTpriceABcTc (c_movep, &(base_move->val));
07188             KPTupdateMove (base_move, best_move);
07189             /* now we call deeper moves */
07190             KPTgoDeeper (depth);
07191             break;
07192           case 2:
07193             /* ------------------------------------------------------------- */
07194             /* Check KPT_AcBTc */
07195             base_move->val = move_val;
07196             c_movep->move_id = KPT_AcB_Tc;
07197             KPTpriceAcBTc (c_movep, &(base_move->val));
07198             KPTupdateMove (base_move, best_move);
07199             /* now we call deeper moves */
07200             KPTgoDeeper (depth);
07201             break;
07202           case 3:
07203             /* ------------------------------------------------------------- */
07204             /* Check KPT_ABTc */
07205             base_move->val = move_val;
07206             c_movep->move_id = KPT_AB_Tc;
07207             KPTpriceABTc (c_movep, &(base_move->val));
07208             KPTupdateMove (base_move, best_move);
07209             /* now we call deeper moves */
07210             KPTgoDeeper (depth);
07211             break;
07212             /* ------------------------------------------------------------- */
07213           default:
07214             EXIT (1, "unknown pos %u", pos);
07215           }
07216         }                       /* end case 2-domino */
07217         break;
07218       default:
07219         EXIT (1, "unknown type %u", type);
07220       }                         /* end switch */
07221     }                           /* end checking shrinking moves for dominoes */
07222   }                             /*end loop through dominoes */
07223   /* now we check if this node can be shrinked from the handle */
07224   type = ((nodeData[nc_id].in_BH && (graphData.n_BH[1] > 1)) ? 2U : 0U) |
07225     ((nodeData[nc_id].in_AH && (graphData.n_AH[1] > 1)) ? 1U : 0U);
07226   switch (type)
07227   {
07228   case 3U:
07229   case 1U:
07230     /* --------------------------------------------------------------------- */
07231     /* Check KPT_AH_AHc */
07232     base_move->val = move_val;
07233     c_movep->move_id = KPT_AH_AHc;
07234     KPTpriceAHAHc (c_movep, &(base_move->val));
07235     KPTupdateMove (base_move, best_move);
07236     /* now we call deeper moves */
07237     KPTgoDeeper (depth);
07238     if (type == 1U)
07239       break;
07240   case 2U:
07241     /* --------------------------------------------------------------------- */
07242     /* Check KPT_BH_BHc */
07243     base_move->val = move_val;
07244     c_movep->move_id = KPT_BH_BHc;
07245     KPTpriceBHBHc (c_movep, &(base_move->val));
07246     KPTupdateMove (base_move, best_move);
07247     /* now we call deeper moves */
07248     KPTgoDeeper (depth);
07249     if (type == 2U)
07250       break;
07251     /* --------------------------------------------------------------------- */
07252     /* Check KPT_AH_AHc_BH_BHc */
07253     base_move->val = move_val;
07254     c_movep->move_id = KPT_AH_AHc_BH_BHc;
07255     KPTpriceAHAHcBHBHc (c_movep, &(base_move->val));
07256     KPTupdateMove (base_move, best_move);
07257     /* now we call deeper moves */
07258     KPTgoDeeper (depth);
07259     break;
07260   case 0:
07261     break;
07262     /* --------------------------------------------------------------------- */
07263   default:
07264     EXIT (1, "Unknown type %u", type);
07265   }
07266   /* ending setting best move */
07267   base_move->val = move_val;
07268   base_move->depth = depth;
07269   MESSAGE (KPT_VRB + 19, "done");
07270   return 0;
07271 }
07272 
07273 /* ========================================================================= */
07276 /* ========================================================================= */
07277 static inline int KPTresetFlags (void)
07278 {
07279   /* local variables */
07280   register unsigned int i = G->nodes->size;
07281   /* loop through all nodes */
07282   while (i--)
07283   {
07284     memset (nodeData[i].added, 0, KPT_MAX_DOM >> 3);
07285     memset (nodeData[i].flipA, 0, KPT_MAX_DOM >> 3);
07286     memset (nodeData[i].flipAc, 0, KPT_MAX_DOM >> 3);
07287     memset (nodeData[i].flipB, 0, KPT_MAX_DOM >> 3);
07288     memset (nodeData[i].flipBc, 0, KPT_MAX_DOM >> 3);
07289     nodeData[i].added_AH = 0;
07290     nodeData[i].added_BH = 0;
07291   }
07292   return 0;
07293 }
07294 
07295 /* ========================================================================= */
07297 /* ========================================================================= */
07298 static inline int KPTStoreFullMove (const unsigned int nc_id,
07299                                     KPTFullMove_t const *const full_move)
07300 {
07301   int rval = 0;
07302   unsigned int l_depth = full_move->depth;
07303   memcpy (&(nodeData[nc_id].full_move), full_move, sizeof (KPTFullMove_t));
07304   while (l_depth--)
07305   {
07306 #if KPT_EDBG < DEBUG
07307     EXIT (full_move->move[l_depth].move_id == KPT_no_move, "Storing "
07308           "KPT_no_move for node %u, depth %u", nc_id, l_depth);
07309 #endif
07310   }
07311   rval = EGbbtreeRemove (tree, nodeData[nc_id].tree_cn);
07312   CHECKRVAL(rval);
07313   rval = !(nodeData[nc_id].tree_cn = EGbbtreeAdd (tree, nodeData + nc_id));
07314   return rval;
07315 }
07316 
07317 /* ========================================================================= */
07319 /* ========================================================================= */
07320 static inline int KPTResetMove (KPTFullMove_t * move)
07321 {
07322   memset (move, 0, sizeof (KPTFullMove_t));
07323   move->move[0].move_id = KPT_no_move;
07324   return 0;
07325 }
07326 
07327 /* ========================================================================= */
07329 /* ========================================================================= */
07330 static inline int KPTupdateNeighMove (KPTFullMove_t * full_move)
07331 {
07332   int rval;
07333   unsigned int const max_depth = full_move->depth + KPT_MAX_DEPTH;
07334   unsigned int no_id[2 * KPT_MAX_DEPTH + 1],
07335     n_depth = 0;
07336   EGlistNode_t *e_it[KPT_MAX_DEPTH * 2];
07337   KPTFullMove_t base_move,
07338     cur_move;
07339   memset (&base_move, 0, sizeof (base_move));
07340   memset (&cur_move, 0, sizeof (base_move));
07341   KPTResetMove (&cur_move);
07342   cur_move.val = DBL_MAX;
07343   base_move.val = 0;
07344   no_id[0] = full_move->move[0].n_id;
07345   KPTSetBestMove (no_id[0], &cur_move, &base_move, 0);
07346   rval = KPTStoreFullMove (no_id[0], &cur_move);
07347   CHECKRVAL(rval);
07348   EGbitSet (node_update, no_id[0]);
07349   e_it[0] = all_nodes[no_id[0]]->edges->begin;
07350   n_depth = 0;
07351   /* for each depth move, we update the neighbours up to depth
07352    * KPT_MAX_DEPTH+full_move->depth */
07353 #if KPT_VRB+19<DEBUG
07354   DPdisplayMove (no_id[0]);
07355 #endif
07356   while (e_it[0])
07357   {
07358     no_id[n_depth + 1] = KPTgetOtherEndId (no_id[n_depth], e_it[n_depth]);
07359     if (!EGbitTest (node_update, no_id[n_depth + 1]))
07360     {
07361       KPTResetMove (&cur_move);
07362       cur_move.val = DBL_MAX;
07363       base_move.val = 0;
07364       KPTSetBestMove (no_id[n_depth + 1], &cur_move, &base_move, 0);
07365       KPTStoreFullMove (no_id[n_depth + 1], &cur_move);
07366       EGbitSet (node_update, no_id[n_depth + 1]);
07367     }
07368     /* now we look at the next neighbour, if we are not at the end of the
07369      * recursion, we go down one more level */
07370     if (n_depth + 1 < max_depth)
07371     {
07372       n_depth++;
07373       e_it[n_depth] = all_nodes[no_id[n_depth]]->edges->begin;
07374     }
07375     /* otherwise we move horizontally in the current level */
07376     else
07377     {
07378       e_it[n_depth] = e_it[n_depth]->next;
07379       /* if the next e_it is null, we have to move up one level, 
07380        * if posible */
07381       while (n_depth && !e_it[n_depth])
07382       {
07383         n_depth--;
07384         e_it[n_depth] = e_it[n_depth]->next;
07385       }
07386     }                           /* end looking at next neighbour */
07387   }                             /* end updating for the given simple move */
07388 #if KPT_VRB+19<DEBUG
07389   DPdisplayMove (no_id[0]);
07390 #endif
07391 /* ========================================================================= */
07392 #if 0
07393 #warning Note that here we update a node too many times, we could \
07394   decrease this by adding a flag for each node and update only if they \
07395   havent been updated so far. of course, this would need to reset the \
07396   flags after we are done.
07397 #endif
07398 /* ========================================================================= */
07399   memset (node_update, 0, sizeof (node_update));
07400   return rval;
07401 }
07402 
07403 /* ========================================================================= */
07404 /* given a residual graph G^*, and a valid DP inequality, it will try to find a
07405  * 'more' violated DP-inequality constraint; the function will not touch the
07406  * data abour the graph nor about the original inequality, but it will alloc
07407  * memory for all data in the new returned inequality. Note too that the number
07408  * of dominos of the new inequality is the same as in the original inequality.
07409  * Finaly, the violation (if it is positive) of the new inequality is returned
07410  * in (*violation). If an error occurs the function will return 1, zero on
07411  * success (this doesn't imply that we were able to find a violated constraint
07412  * from the original onw */
07413 /* ========================================================================= */
07414 int KPtighten (                 /* graph G* data */
07415                 int const n_nodes,
07416                 int const n_edges,
07417                 int const *const edges,
07418                 double const *const external_weight,
07419                 /* original constrain to tighten */
07420                 int const n2dominos,
07421                 int const *const naset,
07422                 int const *const nbset,
07423                 int const *const ntset,
07424                 int const nahandle,
07425                 int const nbhandle,
07426                 int **const aset,
07427                 int **const bset,
07428                 int **const tset,
07429                 int const *const ahandle,
07430                 int const *const bhandle,
07431                 /* new generated constraint */
07432                 int **const new_naset,
07433                 int **const new_nbset,
07434                 int **const new_ntset,
07435                 int *const new_nahandle,
07436                 int *const new_nbhandle,
07437                 int ***const new_aset,
07438                 int ***const new_bset,
07439                 int ***const new_tset,
07440                 int **const new_ahandle,
07441                 int **const new_bhandle,
07442                 double *const violation)
07443 {
07444   /* --------------------------------------------------------------------- */
07445   /* local variables */
07446   EGmemPool_t *mem;
07447   int rval = 0;
07448   unsigned pos,
07449     max_iter = n2dominos * n_nodes * 61,
07450     in_AH = 0,
07451     N1_inA,
07452     N1_inB,
07453     N2_inA,
07454     N2_inB,
07455     N1_id,
07456     N2_id,
07457     N1_inTc,
07458     N2_inTc,
07459     nadom = 0,
07460     nbdom = 0,
07461     in_BH = 0;
07462   double cost_tmp,
07463     l_violation,
07464     o_violation;
07465   register unsigned int i,
07466     j;
07467   KPTNdata_t *nc_data = 0,
07468    *n_data;
07469   KPTFullMove_t cur_move,
07470     base_move;
07471 
07472   /* --------------------------------------------------------------------- */
07473   /* we test that the necesary input is not NULL */
07474   MESSAGE (KPT_VRB + 19, "Entering with n_nodes %d n_edges %d n2dominos %d",
07475            n_nodes, n_edges, n2dominos);
07476   EXIT ((unsigned) n2dominos > KPT_MAX_DOM,
07477         "n2dominos (%d) exced max_n_dom (%u)"
07478         "change the value of KPT_MAX_NODE to an apropiate value", n2dominos,
07479         KPT_MAX_DOM);
07480   EXIT ((unsigned) n_nodes > KPT_MAX_NODE,
07481         "n_nodes (%d) exced max_n_nodes (%u)"
07482         "change the value of KPT_MAX_NODE to an apropiate value", n_nodes,
07483         KPT_MAX_NODE);
07484   TEST (!n_nodes, "graph has no nodes");
07485   TEST (!n_edges, "graph has no edges");
07486   TEST (!edges, "edges is NULL");
07487   TEST (!external_weight, "weight is NULL");
07488   TEST (!n2dominos, "inequality has no dominos");
07489   TEST (!naset, "n_aset is NULL");
07490   TEST (!nbset, "n_bset is NULL");
07491   TEST (!ntset, "n_bset is NULL");
07492   TEST (!nahandle, "inequality has handle");
07493   TEST (!nbhandle, "inequality has handle");
07494   TEST (!aset, "aset is NULL");
07495   TEST (!bset, "bset is NULL");
07496   TEST (!tset, "bset is NULL");
07497   TEST (!ahandle, "handle is NULL");
07498   TEST (!bhandle, "handle is NULL");
07499   TEST (!new_naset, "new_n_aset is NULL");
07500   TEST (!new_nbset, "new_n_bset is NULL");
07501   TEST (!new_ntset, "new_n_bset is NULL");
07502   TEST (!new_nahandle, "new_n_handle is NULL");
07503   TEST (!new_nbhandle, "new_n_handle is NULL");
07504   TEST (!new_aset, "new_aset is NULL");
07505   TEST (!new_bset, "new_bset is NULL");
07506   TEST (!new_tset, "new_bset is NULL");
07507   TEST (!new_ahandle, "new_handle is NULL");
07508   TEST (!new_bhandle, "new_handle is NULL");
07509   TEST (!violation, "violation is NULL");
07510 #if LOG_MODE
07511   /* we save the graph if necesary */
07512   saveGraph ("graph_2tighten.x", n_nodes, n_edges, edges, external_weight);
07513 #endif
07514   /* basic tests */
07515   ADVTESTL (KPT_DBG, (n_nodes < 2) || (n_edges < 1) || !(n2dominos) ||
07516             (nahandle < 1) || (nbhandle < 1) || (n_nodes - nahandle < 1) ||
07517             (n_nodes - nbhandle < 1), 1, "either n_nodes (%d), n_edges (%d),"
07518             " n2dominos (%d), n_ahandle (%d) or n_bhandle (%d) has wrong value",
07519             n_nodes, n_edges, n2dominos, nahandle, nbhandle);
07520   for (i = n2dominos; i--;)
07521   {
07522     ADVTESTL (KPT_EDBG, ((naset[i] < 1) && (nbset[i] < 1)) ||
07523               (naset[i] > ntset[i]) || (nbset[i] > ntset[i]) ||
07524               (ntset[i] > n_nodes), 1, "either naset[%d] (%d) or nbset[%d] "
07525               "(%d) or ntset[%d] (%d) has wrong value, n_nodes %d",
07526               i, naset[i], i, nbset[i], i, ntset[i], n_nodes);
07527     if (naset[i])
07528       nadom++;
07529     if (nbset[i])
07530       nbdom++;
07531   }
07532   ADVTESTL (KPT_EDBG, !(nadom & 1U) || !(nbdom & 1U), 1, "number of Adom %u, "
07533             "number of Bdom %u, they are not odd-odd", nadom, nbdom);
07534 
07535   /* --------------------------------------------------------------------- */
07536   /* basic set-up */
07537   weight = external_weight;
07538   memset (node_update, 0, sizeof (node_update));
07539   mem = EGnewMemPool (512, EGmemPoolNewSize, 4096);
07540   tree = EGnewBbtree (mem, EGdpTightNdataCompare);
07541   nodeData = EGsMalloc (KPTNdata_t, n_nodes);
07542   edgeData = EGsMalloc (KPTEdata_t, n_edges);
07543   all_nodes = EGsMalloc (EGuGraphNode_t *, n_nodes);
07544   all_edges = EGsMalloc (EGuGraphEdge_t *, n_edges);
07545   memset (all_nodes, 0, sizeof (EGuGraphNode_t *) * n_nodes);
07546   memset (nodeData, 0, sizeof (KPTNdata_t) * n_nodes);
07547   memset (edgeData, 0, sizeof (KPTEdata_t) * n_edges);
07548   memset (all_edges, 0, sizeof (EGuGraphEdge_t *) * n_nodes);
07549   memset (&cur_move, 0, sizeof (KPTFullMove_t));
07550   memset (&base_move, 0, sizeof (KPTFullMove_t));
07551   l_violation = (2 * n2dominos + 2 + nadom + nbdom);
07552   (*new_naset) = 0;
07553   (*new_nbset) = 0;
07554   (*new_ntset) = 0;
07555   (*new_nahandle) = 0;
07556   (*new_nbhandle) = 0;
07557   (*new_aset) = 0;
07558   (*new_bset) = 0;
07559   (*new_tset) = 0;
07560   (*new_ahandle) = 0;
07561   (*new_bhandle) = 0;
07562 
07563   /* first we build the graph with its internal data */
07564   memset (&graphData, 0, sizeof (KPTGdata_t));
07565   graphData.n_dominos = n2dominos;
07566   graphData.n_nodes = n_nodes;
07567   G = EGnewUGraph (mem);
07568   G->data = &graphData;
07569 
07570   /* now we initialize all the data structures */
07571   MESSAGE (KPT_VRB + 19, "Initializing");
07572   /* add all nodes */
07573   for (i = 0; i < (unsigned) n_nodes; i++)
07574   {
07575     nodeData[i].full_move.val = DBL_MAX;
07576     all_nodes[i] = EGuGraphAddNode (G, nodeData + i);
07577     rval = !(nodeData[i].tree_cn = EGbbtreeAdd (tree, nodeData + i));
07578     CHECKRVALG(rval,CLEANUP);
07579   }
07580   /* add all edges */
07581   for (i = 0; i < (unsigned) n_edges; i++)
07582   {
07583     all_edges[i] = EGuGraphAddEdge (G, edgeData + i,
07584                                     all_nodes[edges[i << 1]],
07585                                     all_nodes[edges[(i << 1) | 1]]);
07586   }
07587   /* compute handle stuff */
07588   for (i = nahandle; i--;)
07589   {
07590     nodeData[ahandle[i]].in_AH = 1U;
07591     graphData.n_AH[1]++;
07592   }
07593   graphData.n_AH[0] = n_nodes - graphData.n_AH[1];
07594   for (i = nbhandle; i--;)
07595   {
07596     nodeData[bhandle[i]].in_BH = 1U;
07597     graphData.n_BH[1]++;
07598   }
07599   graphData.n_BH[0] = n_nodes - graphData.n_BH[1];
07600   /* now we update information related to the dominoes */
07601   for (i = n2dominos; i--;)
07602   {
07603     if ((graphData.n_A[1][i] = naset[i]))
07604     {
07605       EGbitSet (graphData.A_partition, i);
07606       graphData.n_A[0][i] = ntset[i] - naset[i];
07607     }
07608     if ((graphData.n_B[1][i] = nbset[i]))
07609     {
07610       EGbitSet (graphData.B_partition, i);
07611       graphData.n_B[0][i] = ntset[i] - nbset[i];
07612     }
07613     if (EGbitTest (graphData.A_partition, i)
07614         && EGbitTest (graphData.B_partition, i))
07615       EGbitSet (graphData.Kdom, i);
07616     graphData.n_Tc[i] = n_nodes - ntset[i];
07617     for (j = ntset[i]; j--;)
07618     {
07619       pos = tset[i][j];
07620       EGbitSet (nodeData[pos].It, i);
07621       nodeData[pos].n_in_T++;
07622     }
07623     for (j = naset[i]; j--;)
07624     {
07625       pos = aset[i][j];
07626       EGbitSet (nodeData[pos].Ia, i);
07627       nodeData[pos].n_in_A++;
07628       ADVTESTL (KPT_EDBG, !EGbitTest (nodeData[pos].It, i), 1, "a node %d"
07629                 "is in A_%d but not in T", pos, i);
07630     }
07631     for (j = nbset[i]; j--;)
07632     {
07633       pos = bset[i][j];
07634       EGbitSet (nodeData[pos].Ib, i);
07635       nodeData[pos].n_in_B++;
07636       ADVTESTL (KPT_EDBG, !EGbitTest (nodeData[pos].It, i), 1, "a node %d"
07637                 "is in A_%d but not in T", pos, i);
07638     }
07639     for (j = ntset[i]; j--;)
07640     {
07641       pos = tset[i][j];
07642       if (!EGbitTest (nodeData[pos].Ib, i) == !EGbitTest (nodeData[pos].Ia, i))
07643       {
07644         graphData.n_AdB[1][i]++;
07645         EGbitSet (nodeData[pos].Iadb, i);
07646       }
07647     }
07648     graphData.n_AdB[0][i] = ntset[i] - graphData.n_AdB[1][i];
07649     ADVTESTL (KPT_EDBG, (!graphData.n_AdB[1][i] || !graphData.n_AdB[0][i]) &&
07650               EGbitTest (graphData.Kdom, i), 1,
07651               "domino %u has no 3-partition", i);
07652   }
07653   /* now we update the information for all edges */
07654   for (i = n_edges; i--;)
07655   {
07656     N1_id = all_edges[i]->head->id;
07657     N2_id = all_edges[i]->tail->id;
07658     for (j = n2dominos; j--;)
07659     {
07660       N1_inA = EGbitTest (nodeData[N1_id].Ia, j) ? 1U : 0U;
07661       N1_inB = EGbitTest (nodeData[N1_id].Ib, j) ? 1U : 0U;
07662       N1_inTc = EGbitTest (nodeData[N1_id].It, j) ? 0U : 1U;
07663       N2_inA = EGbitTest (nodeData[N2_id].Ia, j) ? 1U : 0U;
07664       N2_inB = EGbitTest (nodeData[N2_id].Ib, j) ? 1U : 0U;
07665       N2_inTc = EGbitTest (nodeData[N2_id].It, j) ? 0U : 1U;
07666       if ((!N1_inTc && N2_inTc) || (N1_inTc && !N2_inTc))
07667         edgeData[i].num.n_dT++;
07668       if (N1_inTc == N2_inTc)
07669       {
07670         if (N1_inA != N2_inA)
07671           edgeData[i].num.n_AtoAc++;
07672         if (N1_inB != N2_inB)
07673           edgeData[i].num.n_BtoBc++;
07674       }
07675     }
07676     pos = 1U & ((nodeData[N1_id].in_AH ^ nodeData[N2_id].in_AH) ^
07677                 edgeData[i].num.n_AtoAc);
07678     if (pos)
07679       edgeData[i].num.in_AF = 1U;
07680     pos = 1U & ((nodeData[N1_id].in_BH ^ nodeData[N2_id].in_BH) ^
07681                 edgeData[i].num.n_BtoBc);
07682     if (pos)
07683       edgeData[i].num.in_BF = 1U;
07684   }
07685 #if KPT_VRB <= DEBUG-1
07686   KPTDisplayEdges ();
07687 #endif
07688   /* --------------------------------------------------------------------- */
07689   /* now we need to get the best move for each node */
07690   MESSAGE (KPT_VRB + 19, "Setting up best move for all nodes");
07691   /* note that we only need to update moves for nodes whose edges has an edge
07692    * with coefficient of non-zero */
07693   for (i = n_edges; i--;)
07694   {
07695     /* if the edge has a non-zero coefficient, we update it's both ends if they
07696      * haven't been update yet. */
07697     if (edgeData[i].used)
07698     {
07699       if (!EGbitTest (node_update, all_edges[i]->tail->id))
07700       {
07701         KPTResetMove (&cur_move);
07702         cur_move.val = DBL_MAX;
07703         base_move.val = 0;
07704         KPTSetBestMove (all_edges[i]->tail->id, &cur_move, &base_move, 0);
07705         KPTStoreFullMove (all_edges[i]->tail->id, &cur_move);
07706         EGbitSet (node_update, all_edges[i]->tail->id);
07707 #if KPT_VRB+19<DEBUG
07708         DPdisplayMove (all_edges[i]->tail->id);
07709 #endif
07710       }
07711       if (!EGbitTest (node_update, all_edges[i]->head->id))
07712       {
07713         KPTResetMove (&cur_move);
07714         cur_move.val = DBL_MAX;
07715         base_move.val = 0;
07716         KPTSetBestMove (all_edges[i]->head->id, &cur_move, &base_move, 0);
07717         KPTStoreFullMove (all_edges[i]->head->id, &cur_move);
07718         EGbitSet (node_update, all_edges[i]->head->id);
07719 #if KPT_VRB+19<DEBUG
07720         DPdisplayMove (all_edges[i]->head->id);
07721 #endif
07722       }
07723     }
07724   }                             /* end checking all edges */
07725   /* reset the node update flags */
07726   memset (node_update, 0, sizeof (node_update));
07727   MESSAGE (KPT_VRB + 19, "Best move set for all nodes");
07728 
07729   /* --------------------------------------------------------------------- */
07730   /* now we compute the original violation */
07731   o_violation = 2 * n2dominos + 2 + nadom + nbdom;
07732   o_violation = -o_violation;
07733   KPTpriceConstraint (&o_violation);
07734   MESSAGE (KPT_VRB + 19, "Computing Original violation %lg", o_violation);
07735   l_violation = o_violation;
07736 
07737   /* --------------------------------------------------------------------- */
07738   /* now we check if the original constraint is correct */
07739 #if KPT_EDBG < DEBUG
07740   {
07741     double t_violation;
07742     int *e_coeff = EGsMalloc (int, n_edges);
07743     rval = EG2pChecker (n_nodes, n_edges, edges, external_weight, 1,
07744                         &n2dominos, &naset, &nbset, &ntset, &nahandle,
07745                         &nbhandle, &aset, &bset, &tset, &ahandle, &bhandle,
07746                         &t_violation, &e_coeff);
07747     EXIT (rval, "inequality os not wright");
07748     EXIT (fabs (t_violation - o_violation) > 1e-3,
07749           "wrong violation, computed %lf," " checked %lf difference %lf",
07750           o_violation, t_violation, fabs (o_violation - t_violation));
07751     EGfree (e_coeff);
07752   }
07753 #endif
07754 
07755   /* --------------------------------------------------------------------- */
07756   /* now we enter our main loop, while there is a negative move, we keep going
07757    * */
07758   while (((cost_tmp = (nc_data =
07759                        KPTNdata (EGbbtreeMin (tree)->this))->full_move.val)
07760           < -KPTMinImprovement) && max_iter--)
07761   {
07762     MESSAGE (KPT_VRB + 19, "Try to find best move (current best %8.6lf) "
07763              "Iteration: %u", cost_tmp, max_iter);
07764     memcpy (&cur_move, &(nc_data->full_move), sizeof (KPTFullMove_t));
07765 #if KPT_VRB+19<DEBUG
07766     i = cur_move.move[0].n_id;
07767     DPdisplayMove (i);
07768 #endif
07769     /* now check if the movement is infeasible, if so, update the best move and
07770      * move-on */
07771     if (!KPTisFullMoveFeasible (&cur_move))
07772     {
07773       i = cur_move.move[0].n_id;
07774 #if KPT_VRB+0<DEBUG
07775       DPdisplayMove (i);
07776 #endif
07777       MESSAGE (KPT_VRB + 1, "Move for node %u dom %u infeasible", i,
07778                cur_move.move[0].dom);
07779       KPTResetMove (&cur_move);
07780       cur_move.val = DBL_MAX;
07781       base_move.val = 0;
07782       KPTSetBestMove (i, &cur_move, &base_move, 0);
07783       KPTStoreFullMove (i, &cur_move);
07784 #if KPT_VRB+0<DEBUG
07785       DPdisplayMove (i);
07786 #endif
07787       continue;
07788     }
07789     /* now, if the move is good (i.e. non-zero) we reset the flags */
07790     if (cost_tmp < KPTMinImprovement)
07791       KPTresetFlags ();
07792     /* now we perform the move */
07793     MESSAGE (KPT_VRB + 0, "Imp: %8.6lf Tot: %8.6lf node %u move %s depth %u",
07794              cost_tmp, l_violation, cur_move.move[0].n_id,
07795              move_name[cur_move.move[0].move_id], nc_data->full_move.depth);
07796     KPTmakeFullMove (&cur_move);
07797     l_violation += cost_tmp;
07798     /* this check is to be sure if the violation predicted is OK */
07799 #if KPT_EDBG <= DEBUG
07800     EXITRVAL (KPTTestEdges ());
07801     cost_tmp = 2 * n2dominos + 2 + nadom + nbdom;
07802     cost_tmp = -cost_tmp;
07803     KPTpriceConstraint (&cost_tmp);
07804     EXIT ((fabs (cost_tmp - l_violation) > 1e-3) &&
07805           DPdisplayMove ((i =
07806                           cur_move.move[0].n_id)),
07807           "Error computing violation"
07808           ", predicted %8.6lf computed %8.6lf diference %8.6lf", l_violation,
07809           cost_tmp, l_violation - cost_tmp);
07810 #endif
07811     /* now update best move for the node and all its neighbours */
07812     /* update moves */
07813     KPTupdateNeighMove (&cur_move);
07814   }
07815   /* --------------------------------------------------------------------- */
07816   cost_tmp = ((KPTNdata_t *) (EGbbtreeMin (tree)->this))->full_move.val;
07817   MESSAGE (KPT_VRB + 19, "No good moves left (current best %8.6lf)",
07818            (cost_tmp));
07819 
07820   /* --------------------------------------------------------------------- */
07821   if (o_violation > l_violation + 1e-4)
07822     /* now, if we have a violated and better inequality, we save it and send it
07823      * back to the calling function. */
07824   {
07825     MESSAGE (0, "Original: %8.6lf New: %8.6lf Diff: %lg", o_violation,
07826              l_violation, fabs (o_violation - l_violation));
07827     /* look for memory */
07828     (*new_naset) = EGsMalloc (int,
07829                               n2dominos);
07830     (*new_nbset) = EGsMalloc (int,
07831                               n2dominos);
07832     (*new_ntset) = EGsMalloc (int,
07833                               n2dominos);
07834     (*new_aset) = EGsMalloc (int *,
07835                              n2dominos);
07836     (*new_bset) = EGsMalloc (int *,
07837                              n2dominos);
07838     (*new_tset) = EGsMalloc (int *,
07839                              n2dominos);
07840     (*new_nahandle) = 0;
07841     (*new_nbhandle) = 0;
07842     in_AH = graphData.n_AH[1] < graphData.n_AH[0] ? 1 : 0;
07843     in_BH = graphData.n_BH[1] < graphData.n_BH[0] ? 1 : 0;
07844     TESTL (KPT_EDBG,
07845            graphData.n_AH[0] + graphData.n_AH[1] != (unsigned) n_nodes,
07846            "wrong A handle");
07847     TESTL (KPT_EDBG,
07848            graphData.n_BH[0] + graphData.n_BH[1] != (unsigned) n_nodes,
07849            "wrong B handle");
07850     TESTL (KPT_EDBG, !(graphData.n_AH[in_AH]), "handle is empty!");
07851     TESTL (KPT_EDBG, !(graphData.n_BH[in_BH]), "handle is empty!");
07852     (*new_ahandle) = EGsMalloc (int,
07853                                 graphData.n_AH[in_AH]);
07854     (*new_bhandle) = EGsMalloc (int,
07855                                 graphData.n_BH[in_BH]);
07856     for (i = n2dominos; i--;)
07857     {
07858       TESTL (KPT_EDBG,
07859              (!(graphData.n_A[0][i]) && EGbitTest (graphData.A_partition, i)) ||
07860              (!(graphData.n_B[0][i]) && EGbitTest (graphData.B_partition, i)) ||
07861              (!(graphData.n_A[1][i]) && EGbitTest (graphData.A_partition, i)) ||
07862              (!(graphData.n_B[1][i]) && EGbitTest (graphData.B_partition, i)) ||
07863              !(graphData.n_Tc[i]), "domino(%u) with empty component A=(%u,%u)"
07864              ", B=(%u,%u), T^c=%u", i, graphData.n_A[1][i], graphData.n_A[0][i],
07865              graphData.n_B[1][i], graphData.n_B[0][i], graphData.n_Tc[i]);
07866       TESTL (KPT_EDBG, EGbitTest (graphData.Kdom, i)
07867              && (!graphData.n_AdB[0][i]
07868                  || !graphData.n_AdB[1][i]),
07869              "the 2-domino_%d is not a 3-partition", i);
07870       if (graphData.n_A[1][i])
07871         (*new_aset)[i] = EGsMalloc (int,
07872                                     graphData.n_A[1][i]);
07873       else
07874         (*new_aset)[i] = 0;
07875       if (graphData.n_B[1][i])
07876         (*new_bset)[i] = EGsMalloc (int,
07877                                     graphData.n_B[1][i]);
07878       else
07879         (*new_bset)[i] = 0;
07880       (*new_tset)[i] = EGsMalloc (int,
07881                                   n_nodes - graphData.n_Tc[i]);
07882       ((*new_naset)[i]) = 0;
07883       ((*new_nbset)[i]) = 0;
07884       ((*new_ntset)[i]) = 0;
07885     }
07886 
07887     /* we loop through all nodes and put them where they should go */
07888     for (i = n_nodes; i--;)
07889     {
07890       n_data = nodeData + i;
07891       if ((n_data->in_AH & 1U) == in_AH)
07892         (*new_ahandle)[(*new_nahandle)++] = i;
07893       if ((n_data->in_BH & 1U) == in_BH)
07894         (*new_bhandle)[(*new_nbhandle)++] = i;
07895       /* loop through all dominos to check to which one the node belong */
07896       for (j = n2dominos; j--;)
07897       {
07898         if (EGbitTest (n_data->It, j))
07899           (*new_tset)[j][((*new_ntset)[j])++] = i;
07900         if (EGbitTest (n_data->Ia, j))
07901           (*new_aset)[j][((*new_naset)[j])++] = i;
07902         if (EGbitTest (n_data->Ib, j))
07903           (*new_bset)[j][((*new_nbset)[j])++] = i;
07904       }                         /* end loop through dominos for each node */
07905     }                           /* end loop every node */
07906 
07907     TESTL (KPT_EDBG, (in_AH ? ((*new_nahandle) != (signed) graphData.n_AH[1]) :
07908                       ((*new_nahandle) != (signed) graphData.n_AH[0])),
07909            "Ahandle size " "doesn't agree with what we have found");
07910     TESTL (KPT_EDBG,
07911            (in_BH ? ((*new_nbhandle) != (signed) graphData.n_BH[1])
07912             : ((*new_nbhandle) != (signed) graphData.n_BH[0])),
07913            "Bhandle size " "doesn't agree with what we have found");
07914     for (i = n2dominos; i--;)
07915     {
07916       TESTL (KPT_EDBG, (*new_naset)[i] != (signed) graphData.n_A[1][i],
07917              "size of A_[%u] doesn't match (%d,%u)", i, (*new_naset)[i],
07918              graphData.n_A[1][i]);
07919       TESTL (KPT_EDBG, (*new_nbset)[i] != (signed) graphData.n_B[1][i],
07920              "size of B_[%u] doesn't match (%d,%u)", i, (*new_nbset)[i],
07921              graphData.n_B[1][i]);
07922     }
07923     /* --------------------------------------------------------------------- */
07924     /* now we check that the inequality os wroight, we use the 2pchecker . */
07925 #if KPT_EDBG < DEBUG
07926     {
07927       double t_violation;
07928       int *e_coeff = EGsMalloc (int, n_edges);
07929       rval = EG2pChecker (n_nodes, n_edges, edges, external_weight, 1,
07930                           &n2dominos, new_naset, new_nbset, new_ntset,
07931                           new_nahandle, new_nbhandle, new_aset, new_bset,
07932                           new_tset, new_ahandle, new_bhandle, &t_violation,
07933                           &e_coeff);
07934       EXIT (rval, "Inequality is wrong");
07935       EXIT (fabs (t_violation - l_violation) > 1e-3,
07936             "violation is wrongly computed"
07937             ", given %lf, computed %lf, diff %lf", l_violation, t_violation,
07938             fabs (l_violation - t_violation));
07939       EGfree (e_coeff);
07940     }
07941 #endif
07942   }                             /* end saving newly found constraint */
07943   /* ending */
07944   CLEANUP:
07945   MESSAGE (KPT_VRB + 19, "Clearing graph");
07946   EGuGraphClearMP (G, nullFreeMP, nullFreeMP, nullFreeMP, mem, mem, mem);
07947   MESSAGE (KPT_VRB + 19, "Freing graph");
07948   EGfreeUGraph (G);
07949   MESSAGE (KPT_VRB + 19, "Freing all_nodes");
07950   EGfree (all_nodes);
07951   MESSAGE (KPT_VRB + 19, "Freing all_edges");
07952   EGfree (all_edges);
07953   MESSAGE (KPT_VRB + 19, "Freing tree");
07954   EGfreeBbtree (tree);
07955   MESSAGE (KPT_VRB + 19, "Freing nodeData");
07956   EGfree (nodeData);
07957   MESSAGE (KPT_VRB + 19, "Freing edgeData");
07958   EGfree (edgeData);
07959   MESSAGE (KPT_VRB + 19, "Freing mempool");
07960   EGfreeMemPool (mem);
07961   *violation = l_violation;
07962   MESSAGE (KPT_VRB + 19, "Ending with violation %8.6lf", *violation);
07963   return rval;
07964 }
07965 #else
07966 int KPtighten (                 /* graph G* data */
07967                 int const n_nodes,
07968                 int const n_edges,
07969                 int const *const edges,
07970                 double const *const weight,
07971                 /* original constrain to tighten */
07972                 int const n2dominos,
07973                 int const *const naset,
07974                 int const *const nbset,
07975                 int const *const ntset,
07976                 int const nahandle,
07977                 int const nbhandle,
07978                 int **const aset,
07979                 int **const bset,
07980                 int **const tset,
07981                 int const *const ahandle,
07982                 int const *const bhandle,
07983                 /* new generated constraint */
07984                 int **const new_naset,
07985                 int **const new_nbset,
07986                 int **const new_ntset,
07987                 int *const new_nahandle,
07988                 int *const new_nbhandle,
07989                 int ***const new_aset,
07990                 int ***const new_bset,
07991                 int ***const new_tset,
07992                 int **const new_ahandle,
07993                 int **const new_bhandle,
07994                 double *const violation)
07995 {
07996   (*new_naset) = 0;
07997   (*new_nbset) = 0;
07998   (*new_ntset) = 0;
07999   (*new_nahandle) = 0;
08000   (*new_nbhandle) = 0;
08001   (*new_aset) = 0;
08002   (*new_bset) = 0;
08003   (*new_tset) = 0;
08004   (*new_ahandle) = 0;
08005   (*new_bhandle) = 0;
08006   (*violation) = 0;
08007   return 0;
08008 }
08009 #endif

Generated on Thu Oct 20 14:58:40 2005 for DominoParitySeparator by  doxygen 1.4.5