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

  Synopsis    [Updates the BDD variable group tree before a shuffle.]

  Description [Updates the BDD variable group tree before a shuffle.
  Returns 1 if successful; 0 otherwise.]

  SideEffects [Changes the BDD variable group tree.]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Updates the BDD variable group tree before a shuffle.]

Description [Updates the BDD variable group tree before a shuffle.
Returns 1 if successful; 0 otherwise.]

SideEffects [Changes the BDD variable group tree.]


Function Synopsis [ Updates the BDD variable group tree before a shuffle . ] Description [ Updates the BDD variable group tree before a shuffle . Returns 1 if successful ; 0 otherwise . ] SideEffects [ Changes the BDD variable group tree . ]
static int
ddUpdateMtrTree(
  DdManager * table,
  MtrNode * treenode,
  int * perm,
  int * invperm)
{
    int i, size;
    int index, level, minLevel, maxLevel, minIndex;
    if (treenode == NULL) return(1);
    minLevel = CUDD_MAXINDEX;
    maxLevel = 0;
    minIndex = -1;
    for (i = treenode->low; i < treenode->low + treenode->size; i++) {
        index = table->invperm[i];
        level = perm[index];
        if (level < minLevel) {
            minLevel = level;
            minIndex = index;
        }
        if (level > maxLevel)
            maxLevel = level;
    }
    size = maxLevel - minLevel + 1;
    if (minIndex == -1) return(0);
    if (size == treenode->size) {
        treenode->low = minLevel;
        treenode->index = minIndex;
    } else {
        return(0);
    }
    if (treenode->child != NULL) {
        if (!ddUpdateMtrTree(table, treenode->child, perm, invperm))
            return(0);
    }
    if (treenode->younger != NULL) {
        if (!ddUpdateMtrTree(table, treenode->younger, perm, invperm))
            return(0);
    }
    return(1);
}
static int ddUpdateMtrTree ( DdManager * table , MtrNode * treenode , int * perm , int * invperm ) { int i , size ; int index , level , minLevel , maxLevel , minIndex ; if ( treenode == NULL ) return ( 1 ) ; minLevel = CUDD_MAXINDEX ; maxLevel = 0 ; minIndex = -1 ; for ( i = treenode -> low ; i < treenode -> low + treenode -> size ; i ++ ) { index = table -> invperm [ i ] ; level = perm [ index ] ; if ( level < minLevel ) { minLevel = level ; minIndex = index ; } if ( level > maxLevel ) maxLevel = level ; } size = maxLevel - minLevel + 1 ; if ( minIndex == -1 ) return ( 0 ) ; if ( size == treenode -> size ) { treenode -> low = minLevel ; treenode -> index = minIndex ; } else { return ( 0 ) ; } if ( treenode -> child != NULL ) { if ( ! ddUpdateMtrTree ( table , treenode -> child , perm , invperm ) ) return ( 0 ) ; } if ( treenode -> younger != NULL ) { if ( ! ddUpdateMtrTree ( table , treenode -> younger , perm , invperm ) ) return ( 0 ) ; } return ( 1 ) ; }
Function
Synopsis    [Updates the BDD variable group tree before a shuffle.]
Function Synopsis [ Updates the BDD variable group tree before a shuffle . ]
/* i : level */