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

  Synopsis    [Reorders by applying a sliding window of width 2.]

  Description [Reorders by applying a sliding window of width 2.
  Tries both permutations of the variables in a window
  that slides from low to high.  Assumes that no dead nodes are
  present.  Returns 1 in case of success; 0 otherwise.]

  SideEffects [None]

******************************************************************************/
Function
Synopsis    [Reorders by applying a sliding window of width 2.]

Description [Reorders by applying a sliding window of width 2.
Tries both permutations of the variables in a window
that slides from low to high.  Assumes that no dead nodes are
present.  Returns 1 in case of success; 0 otherwise.]


Function Synopsis [ Reorders by applying a sliding window of width 2 . ] Description [ Reorders by applying a sliding window of width 2 . Tries both permutations of the variables in a window that slides from low to high . Assumes that no dead nodes are present . Returns 1 in case of success ; 0 otherwise . ]
static int
ddWindow2(
  DdManager * table,
  int  low,
  int  high)
{
    int x;
    int res;
    int size;
#ifdef DD_DEBUG
    assert(low >= 0 && high < table->size);
#endif
    if (high-low < 1) return(0);
    res = table->keys - table->isolated;
    for (x = low; x < high; x++) {
        size = res;
        res = cuddSwapInPlace(table,x,x+1);
        if (res == 0) return(0);
        if (res >= size) { 
            res = cuddSwapInPlace(table,x,x+1);
            if (res == 0) return(0);
        }
#ifdef DD_STATS
        if (res < size) {
            (void) fprintf(table->out,"-");
        } else {
            (void) fprintf(table->out,"=");
        }
        fflush(table->out);
#endif
    }
    return(1);
}
static int ddWindow2 ( DdManager * table , int low , int high ) { int x ; int res ; int size ; #ifdef DD_DEBUG assert ( low >= 0 && high < table -> size ) ; #endif if ( high - low < 1 ) return ( 0 ) ; res = table -> keys - table -> isolated ; for ( x = low ; x < high ; x ++ ) { size = res ; res = cuddSwapInPlace ( table , x , x + 1 ) ; if ( res == 0 ) return ( 0 ) ; if ( res >= size ) { res = cuddSwapInPlace ( table , x , x + 1 ) ; if ( res == 0 ) return ( 0 ) ; } #ifdef DD_STATS if ( res < size ) { ( void ) fprintf ( table -> out , " " ) ; } else { ( void ) fprintf ( table -> out , " " ) ; } fflush ( table -> out ) ; #endif } return ( 1 ) ; }
Function
Synopsis    [Reorders by applying a sliding window of width 2.]
Function Synopsis [ Reorders by applying a sliding window of width 2 . ]
/* no improvement: undo permutation */