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

  Synopsis    [Finds the two literal clauses of a DD.]

  Description [Returns the one- and two-literal clauses of a DD.
  Returns a pointer to the structure holding the clauses if
  successful; NULL otherwise.  For a constant DD, the empty set of clauses
  is returned.  This is obviously correct for a non-zero constant.  For the
  constant zero, it is based on the assumption that only those clauses
  containing variables in the support of the function are considered.  Since
  the support of a constant function is empty, no clauses are returned.]

  SideEffects [None]

  SeeAlso     [Cudd_FindEssential]

******************************************************************************/
Function
Synopsis    [Finds the two literal clauses of a DD.]

Description [Returns the one- and two-literal clauses of a DD.
Returns a pointer to the structure holding the clauses if
successful; NULL otherwise.  For a constant DD, the empty set of clauses
is returned.  This is obviously correct for a non-zero constant.  For the
constant zero, it is based on the assumption that only those clauses
containing variables in the support of the function are considered.  Since
the support of a constant function is empty, no clauses are returned.]




Function Synopsis [ Finds the two literal clauses of a DD . ] Description [ Returns the one - and two - literal clauses of a DD . Returns a pointer to the structure holding the clauses if successful ; NULL otherwise . For a constant DD the empty set of clauses is returned . This is obviously correct for a non - zero constant . For the constant zero it is based on the assumption that only those clauses containing variables in the support of the function are considered . Since the support of a constant function is empty no clauses are returned . ]
DdTlcInfo *
Cudd_FindTwoLiteralClauses(
  DdManager * dd,
  DdNode * f)
{
    DdTlcInfo *res;
    st__table *table;
    st__generator *gen;
    DdTlcInfo *tlc;
    DdNode *node;
    int size = dd->size;
    if (Cudd_IsConstant(f)) {
        res = emptyClauseSet();
        return(res);
    }
    table = st__init_table( st__ptrcmp, st__ptrhash);
    if (table == NULL) return(NULL);
    Tolv = bitVectorAlloc(size);
    if (Tolv == NULL) {
        st__free_table(table);
        return(NULL);
    }
    Tolp = bitVectorAlloc(size);
    if (Tolp == NULL) {
        st__free_table(table);
        bitVectorFree(Tolv);
        return(NULL);
    }
    Eolv = bitVectorAlloc(size);
    if (Eolv == NULL) {
        st__free_table(table);
        bitVectorFree(Tolv);
        bitVectorFree(Tolp);
        return(NULL);
    }
    Eolp = bitVectorAlloc(size);
    if (Eolp == NULL) {
        st__free_table(table);
        bitVectorFree(Tolv);
        bitVectorFree(Tolp);
        bitVectorFree(Eolv);
        return(NULL);
    }
    res = ddFindTwoLiteralClausesRecur(dd,f,table);
    st__foreach_item(table, gen, (const char **)&node, (char **)&tlc) {
        if (node != f) {
            Cudd_tlcInfoFree(tlc);
        }
    }
    st__free_table(table);
    bitVectorFree(Tolv);
    bitVectorFree(Tolp);
    bitVectorFree(Eolv);
    bitVectorFree(Eolp);
    if (res != NULL) {
        int i;
        for (i = 0; !sentinelp(res->vars[i], res->vars[i+1]); i += 2);
        res->cnt = i >> 1;
    }
    return(res);
}
DdTlcInfo * Cudd_FindTwoLiteralClauses ( DdManager * dd , DdNode * f ) { DdTlcInfo * res ; st__table * table ; st__generator * gen ; DdTlcInfo * tlc ; DdNode * node ; int size = dd -> size ; if ( Cudd_IsConstant ( f ) ) { res = emptyClauseSet ( ) ; return ( res ) ; } table = st__init_table ( st__ptrcmp , st__ptrhash ) ; if ( table == NULL ) return ( NULL ) ; Tolv = bitVectorAlloc ( size ) ; if ( Tolv == NULL ) { st__free_table ( table ) ; return ( NULL ) ; } Tolp = bitVectorAlloc ( size ) ; if ( Tolp == NULL ) { st__free_table ( table ) ; bitVectorFree ( Tolv ) ; return ( NULL ) ; } Eolv = bitVectorAlloc ( size ) ; if ( Eolv == NULL ) { st__free_table ( table ) ; bitVectorFree ( Tolv ) ; bitVectorFree ( Tolp ) ; return ( NULL ) ; } Eolp = bitVectorAlloc ( size ) ; if ( Eolp == NULL ) { st__free_table ( table ) ; bitVectorFree ( Tolv ) ; bitVectorFree ( Tolp ) ; bitVectorFree ( Eolv ) ; return ( NULL ) ; } res = ddFindTwoLiteralClausesRecur ( dd , f , table ) ; st__foreach_item ( table , gen , ( const char * * ) & node , ( char * * ) & tlc ) { if ( node != f ) { Cudd_tlcInfoFree ( tlc ) ; } } st__free_table ( table ) ; bitVectorFree ( Tolv ) ; bitVectorFree ( Tolp ) ; bitVectorFree ( Eolv ) ; bitVectorFree ( Eolp ) ; if ( res != NULL ) { int i ; for ( i = 0 ; ! sentinelp ( res -> vars [ i ] , res -> vars [ i + 1 ] ) ; i += 2 ) ; res -> cnt = i >> 1 ; } return ( res ) ; }
Function
Synopsis    [Finds the two literal clauses of a DD.]
Function Synopsis [ Finds the two literal clauses of a DD . ]
/* Dispose of table contents and free table. */