abc/src/bdd/cudd/cuddZddSymm.c
/**Function********************************************************************

  Synopsis [Undoes the swap of two groups.]

  Description [Undoes the swap of two groups. x is assumed to be the
  bottom variable of the first group. y is assumed to be the top
  variable of the second group.  Returns 1 if successful; 0 otherwise.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis [Undoes the swap of two groups.]

Description [Undoes the swap of two groups. x is assumed to be the
bottom variable of the first group. y is assumed to be the top
variable of the second group.  Returns 1 if successful; 0 otherwise.]




Function Synopsis [ Undoes the swap of two groups . ] Description [ Undoes the swap of two groups . x is assumed to be the bottom variable of the first group . y is assumed to be the top variable of the second group . Returns 1 if successful ; 0 otherwise . ]
static int
zdd_group_move_backward(
  DdManager * table,
  int  x,
  int  y)
{
    int        size = -1;
    int        i, temp, gxtop, gxbot, gybot, yprev;
#ifdef DD_DEBUG
    assert(x < y);      
#endif
    gxtop = table->subtableZ[x].next;
    gxbot = x;
    gybot = table->subtableZ[y].next;
    while (table->subtableZ[gybot].next != (unsigned) y)
        gybot = table->subtableZ[gybot].next;
    yprev = gybot;
    while (x <= y) {
        while (y > gxtop) {
            temp = table->subtableZ[x].next;
            if (temp == x)
                temp = y;
            i = gxtop;
            for (;;) {
                if (table->subtableZ[i].next == (unsigned) x) {
                    table->subtableZ[i].next = y;
                    break;
                } else {
                    i = table->subtableZ[i].next;
                }
            }
            if (table->subtableZ[y].next != (unsigned) y) {
                table->subtableZ[x].next = table->subtableZ[y].next;
            } else {
                table->subtableZ[x].next = x;
            }
            if (yprev != y) {
                table->subtableZ[yprev].next = x;
            } else {
                yprev = x;
            }
            table->subtableZ[y].next = temp;
            size = cuddZddSwapInPlace(table, x, y);
            if (size == 0)
                return(0);
            y = x;
            x--;
        } 
        if (table->subtableZ[y].next <= (unsigned) y) {
            gybot = y;
        } else {
            y = table->subtableZ[y].next;
        }
        yprev = gxtop;
        gxtop++;
        gxbot++;
        x = gxbot;
    } 
    return(size);
}
static int zdd_group_move_backward ( DdManager * table , int x , int y ) { int size = -1 ; int i , temp , gxtop , gxbot , gybot , yprev ; #ifdef DD_DEBUG assert ( x < y ) ; #endif gxtop = table -> subtableZ [ x ] . next ; gxbot = x ; gybot = table -> subtableZ [ y ] . next ; while ( table -> subtableZ [ gybot ] . next != ( unsigned ) y ) gybot = table -> subtableZ [ gybot ] . next ; yprev = gybot ; while ( x <= y ) { while ( y > gxtop ) { temp = table -> subtableZ [ x ] . next ; if ( temp == x ) temp = y ; i = gxtop ; for ( ; ; ) { if ( table -> subtableZ [ i ] . next == ( unsigned ) x ) { table -> subtableZ [ i ] . next = y ; break ; } else { i = table -> subtableZ [ i ] . next ; } } if ( table -> subtableZ [ y ] . next != ( unsigned ) y ) { table -> subtableZ [ x ] . next = table -> subtableZ [ y ] . next ; } else { table -> subtableZ [ x ] . next = x ; } if ( yprev != y ) { table -> subtableZ [ yprev ] . next = x ; } else { yprev = x ; } table -> subtableZ [ y ] . next = temp ; size = cuddZddSwapInPlace ( table , x , y ) ; if ( size == 0 ) return ( 0 ) ; y = x ; x -- ; } if ( table -> subtableZ [ y ] . next <= ( unsigned ) y ) { gybot = y ; } else { y = table -> subtableZ [ y ] . next ; } yprev = gxtop ; gxtop ++ ; gxbot ++ ; x = gxbot ; } return ( size ) ; }
Function
Synopsis [Undoes the swap of two groups.]
Function Synopsis [ Undoes the swap of two groups . ]
/* we assume that x < y */ /* Find top and bottom of the two groups. */ /* Set correct symmetries. */ /* while y > gxtop */ /* Trying to find the next y. */ /* while x <= y, end of group movement backward */