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

  Synopsis    [Reorders variables according to given permutation.]

  Description [Reorders variables according to given permutation.
  The i-th entry of the permutation array contains the index of the variable
  that should be brought to the i-th level.  The size of the array should be
  equal or greater to the number of variables currently in use.
  Returns 1 in case of success; 0 otherwise.]

  SideEffects [Changes the variable order for all diagrams and clears
  the cache.]

  SeeAlso [Cudd_ReduceHeap]

******************************************************************************/
Function
Synopsis    [Reorders variables according to given permutation.]

Description [Reorders variables according to given permutation.
The i-th entry of the permutation array contains the index of the variable
that should be brought to the i-th level.  The size of the array should be
equal or greater to the number of variables currently in use.
Returns 1 in case of success; 0 otherwise.]

SideEffects [Changes the variable order for all diagrams and clears
the cache.]


Function Synopsis [ Reorders variables according to given permutation . ] Description [ Reorders variables according to given permutation . The i - th entry of the permutation array contains the index of the variable that should be brought to the i - th level . The size of the array should be equal or greater to the number of variables currently in use . Returns 1 in case of success ; 0 otherwise . ] SideEffects [ Changes the variable order for all diagrams and clears the cache . ]
int
Cudd_ShuffleHeap(
  DdManager * table ,
  int * permutation )
{
    int result;
    int i;
    int identity = 1;
    int *perm;
    for (i = 0; i < table->size; i++) {
        if (permutation[i] != table->invperm[i]) {
            identity = 0;
            break;
        }
    }
    if (identity == 1) {
        return(1);
    }
    if (!ddReorderPreprocess(table)) return(0);
    if (table->keys > table->peakLiveNodes) {
        table->peakLiveNodes = table->keys;
    }
    perm = ABC_ALLOC(int, table->size);
    for (i = 0; i < table->size; i++)
        perm[permutation[i]] = i;
    if (!ddCheckPermuation(table,table->tree,perm,permutation)) {
        ABC_FREE(perm);
        return(0);
    }
    if (!ddUpdateMtrTree(table,table->tree,perm,permutation)) {
        ABC_FREE(perm);
        return(0);
    }
    ABC_FREE(perm);
    result = ddShuffle(table,permutation);
    if (!ddReorderPostprocess(table)) return(0);
    return(result);
}
int Cudd_ShuffleHeap ( DdManager * table , int * permutation ) { int result ; int i ; int identity = 1 ; int * perm ; for ( i = 0 ; i < table -> size ; i ++ ) { if ( permutation [ i ] != table -> invperm [ i ] ) { identity = 0 ; break ; } } if ( identity == 1 ) { return ( 1 ) ; } if ( ! ddReorderPreprocess ( table ) ) return ( 0 ) ; if ( table -> keys > table -> peakLiveNodes ) { table -> peakLiveNodes = table -> keys ; } perm = ABC_ALLOC ( int , table -> size ) ; for ( i = 0 ; i < table -> size ; i ++ ) perm [ permutation [ i ] ] = i ; if ( ! ddCheckPermuation ( table , table -> tree , perm , permutation ) ) { ABC_FREE ( perm ) ; return ( 0 ) ; } if ( ! ddUpdateMtrTree ( table , table -> tree , perm , permutation ) ) { ABC_FREE ( perm ) ; return ( 0 ) ; } ABC_FREE ( perm ) ; result = ddShuffle ( table , permutation ) ; if ( ! ddReorderPostprocess ( table ) ) return ( 0 ) ; return ( result ) ; }
Function
Synopsis    [Reorders variables according to given permutation.]
Function Synopsis [ Reorders variables according to given permutation . ]
/* DD manager */ /* required variable permutation */ /* Don't waste time in case of identity permutation. */