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

  Synopsis    [Counts the number of roots.]

  Description [Counts the number of roots at the levels between lower and
  upper.  The computation is based on breadth-first search.
  A node is a root if it is not reachable from any previously visited node.
  (All the nodes at level lower are therefore considered roots.)
  The visited flag uses the LSB of the next pointer.  Returns the root
  count. The roots that are constant nodes are always ignored.]

  SideEffects [None]

  SeeAlso     [ddClearGlobal]

******************************************************************************/
Function
Synopsis    [Counts the number of roots.]

Description [Counts the number of roots at the levels between lower and
upper.  The computation is based on breadth-first search.
A node is a root if it is not reachable from any previously visited node.
(All the nodes at level lower are therefore considered roots.)
The visited flag uses the LSB of the next pointer.  Returns the root
count. The roots that are constant nodes are always ignored.]




Function Synopsis [ Counts the number of roots . ] Description [ Counts the number of roots at the levels between lower and upper . The computation is based on breadth - first search . A node is a root if it is not reachable from any previously visited node . ( All the nodes at level lower are therefore considered roots . ) The visited flag uses the LSB of the next pointer . Returns the root count . The roots that are constant nodes are always ignored . ]
static int
ddCountRoots(
  DdManager * table,
  int  lower,
  int  upper)
{
    int i,j;
    DdNode *f;
    DdNodePtr *nodelist;
    DdNode *sentinel = &(table->sentinel);
    int slots;
    int roots = 0;
    int maxlevel = lower;
    for (i = lower; i <= upper; i++) {
        nodelist = table->subtables[i].nodelist;
        slots = table->subtables[i].slots;
        for (j = 0; j < slots; j++) {
            f = nodelist[j];
            while (f != sentinel) {
                if (!Cudd_IsComplement(f->next)) {
                    if (f != table->vars[f->index]) {
                        roots++;
                    }
                }
                if (!Cudd_IsConstant(cuddT(f))) {
                    cuddT(f)->next = Cudd_Complement(cuddT(f)->next);
                    if (table->perm[cuddT(f)->index] > maxlevel)
                        maxlevel = table->perm[cuddT(f)->index];
                }
                if (!Cudd_IsConstant(cuddE(f))) {
                    Cudd_Regular(cuddE(f))->next =
                        Cudd_Complement(Cudd_Regular(cuddE(f))->next);
                    if (table->perm[Cudd_Regular(cuddE(f))->index] > maxlevel)
                        maxlevel = table->perm[Cudd_Regular(cuddE(f))->index];
                }
                f = Cudd_Regular(f->next);
            }
        }
    }
    ddClearGlobal(table, lower, maxlevel);
    return(roots);
}
static int ddCountRoots ( DdManager * table , int lower , int upper ) { int i , j ; DdNode * f ; DdNodePtr * nodelist ; DdNode * sentinel = & ( table -> sentinel ) ; int slots ; int roots = 0 ; int maxlevel = lower ; for ( i = lower ; i <= upper ; i ++ ) { nodelist = table -> subtables [ i ] . nodelist ; slots = table -> subtables [ i ] . slots ; for ( j = 0 ; j < slots ; j ++ ) { f = nodelist [ j ] ; while ( f != sentinel ) { if ( ! Cudd_IsComplement ( f -> next ) ) { if ( f != table -> vars [ f -> index ] ) { roots ++ ; } } if ( ! Cudd_IsConstant ( cuddT ( f ) ) ) { cuddT ( f ) -> next = Cudd_Complement ( cuddT ( f ) -> next ) ; if ( table -> perm [ cuddT ( f ) -> index ] > maxlevel ) maxlevel = table -> perm [ cuddT ( f ) -> index ] ; } if ( ! Cudd_IsConstant ( cuddE ( f ) ) ) { Cudd_Regular ( cuddE ( f ) ) -> next = Cudd_Complement ( Cudd_Regular ( cuddE ( f ) ) -> next ) ; if ( table -> perm [ Cudd_Regular ( cuddE ( f ) ) -> index ] > maxlevel ) maxlevel = table -> perm [ Cudd_Regular ( cuddE ( f ) ) -> index ] ; } f = Cudd_Regular ( f -> next ) ; } } } ddClearGlobal ( table , lower , maxlevel ) ; return ( roots ) ; }
Function
Synopsis    [Counts the number of roots.]
Function Synopsis [ Counts the number of roots . ]
/* A node is a root of the DAG if it cannot be
                ** reached by nodes above it. If a node was never
                ** reached during the previous depth-first searches,
                ** then it is a root, and we start a new depth-first
                ** search from it.
                */