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

  Synopsis    [Converts a path of a ZDD representing a cover to a string.]

  Description [Converts a path of a ZDD representing a cover to a
  string.  The string represents an implicant of the cover.  The path
  is typically produced by Cudd_zddForeachPath.  Returns a pointer to
  the string if successful; NULL otherwise.  If the str input is NULL,
  it allocates a new string.  The string passed to this function must
  have enough room for all variables and for the terminator.]

  SideEffects [None]

  SeeAlso     [Cudd_zddForeachPath]

******************************************************************************/
Function
Synopsis    [Converts a path of a ZDD representing a cover to a string.]

Description [Converts a path of a ZDD representing a cover to a
string.  The string represents an implicant of the cover.  The path
is typically produced by Cudd_zddForeachPath.  Returns a pointer to
the string if successful; NULL otherwise.  If the str input is NULL,
it allocates a new string.  The string passed to this function must
have enough room for all variables and for the terminator.]




Function Synopsis [ Converts a path of a ZDD representing a cover to a string . ] Description [ Converts a path of a ZDD representing a cover to a string . The string represents an implicant of the cover . The path is typically produced by Cudd_zddForeachPath . Returns a pointer to the string if successful ; NULL otherwise . If the str input is NULL it allocates a new string . The string passed to this function must have enough room for all variables and for the terminator . ]
char *
Cudd_zddCoverPathToString(
  DdManager *zdd                ,
  int *path                     ,
  char *str                     
  )
{
    int nvars = zdd->sizeZ;
    int i;
    char *res;
    if (nvars & 1) return(NULL);
    nvars >>= 1;
    if (str == NULL) {
        res = ABC_ALLOC(char, nvars+1);
        if (res == NULL) return(NULL);
    } else {
        res = str;
    }
    for (i = 0; i < nvars; i++) {
        int v = (path[2*i] << 2) | path[2*i+1];
        switch (v) {
        case 0:
        case 2:
        case 8:
        case 10:
            res[i] = '-';
            break;
        case 1:
        case 9:
            res[i] = '0';
            break;
        case 4:
        case 6:
            res[i] = '1';
            break;
        default:
            res[i] = '?';
        }
    }
    res[nvars] = 0;
    return(res);
}
char * Cudd_zddCoverPathToString ( DdManager * zdd , int * path , char * str ) { int nvars = zdd -> sizeZ ; int i ; char * res ; if ( nvars & 1 ) return ( NULL ) ; nvars >>= 1 ; if ( str == NULL ) { res = ABC_ALLOC ( char , nvars + 1 ) ; if ( res == NULL ) return ( NULL ) ; } else { res = str ; } for ( i = 0 ; i < nvars ; i ++ ) { int v = ( path [ 2 * i ] << 2 ) | path [ 2 * i + 1 ] ; switch ( v ) { case 0 : case 2 : case 8 : case 10 : res [ i ] = ' ' ; break ; case 1 : case 9 : res [ i ] = ' ' ; break ; case 4 : case 6 : res [ i ] = ' ' ; break ; default : res [ i ] = ' ' ; } } res [ nvars ] = 0 ; return ( res ) ; }
Function
Synopsis    [Converts a path of a ZDD representing a cover to a string.]
Function Synopsis [ Converts a path of a ZDD representing a cover to a string . ]
/* DD manager */ /* path of ZDD representing a cover */ /* pointer to string to use if != NULL */