abc/src/bdd/extrab/extraBddSymm.c
/**Function********************************************************************

  Synopsis    [Creates the symmetry information structure from ZDD.]

  Description [ZDD representation of symmetries is the set of cubes, each
  of which has two variables in the positive polarity. These variables correspond
  to the symmetric variable pair.]

  SideEffects []

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Creates the symmetry information structure from ZDD.]

Description [ZDD representation of symmetries is the set of cubes, each
of which has two variables in the positive polarity. These variables correspond
to the symmetric variable pair.]




Function Synopsis [ Creates the symmetry information structure from ZDD . ] Description [ ZDD representation of symmetries is the set of cubes each of which has two variables in the positive polarity . These variables correspond to the symmetric variable pair . ]
Extra_SymmInfo_t * Extra_SymmPairsCreateFromZdd( DdManager * dd, DdNode * zPairs, DdNode * bSupp )
{
    int i;
    int nSuppSize;
    Extra_SymmInfo_t * p;
    int * pMapVars2Nums;
    DdNode * bTemp;
    DdNode * zSet, * zCube, * zTemp;
    int iVar1, iVar2;
    nSuppSize = Extra_bddSuppSize( dd, bSupp );
    p = Extra_SymmPairsAllocate( nSuppSize );
    pMapVars2Nums = ABC_ALLOC( int, dd->size );
    memset( pMapVars2Nums, 0, dd->size * sizeof(int) );
    p->nVarsMax = dd->size;
    p->nNodes   = 0;
    for ( i = 0, bTemp = bSupp; bTemp != b1; bTemp = cuddT(bTemp), i++ )
    {
        p->pVars[i] = bTemp->index;
        pMapVars2Nums[bTemp->index] = i;
    }
    zSet = zPairs;   Cudd_Ref( zSet );
    while ( zSet != z0 )
    {
        zCube  = Extra_zddSelectOneSubset( dd, zSet );    Cudd_Ref( zCube );
        assert( cuddT( cuddT(zCube) ) == z1 );
        iVar1 = zCube->index/2;
        iVar2 = cuddT(zCube)->index/2;
        if ( pMapVars2Nums[iVar1] < pMapVars2Nums[iVar2] )
            p->pSymms[ pMapVars2Nums[iVar1] ][ pMapVars2Nums[iVar2] ] = 1;
        else
            p->pSymms[ pMapVars2Nums[iVar2] ][ pMapVars2Nums[iVar1] ] = 1;
        p->nSymms ++;
        zSet = Cudd_zddDiff( dd, zTemp = zSet, zCube );     Cudd_Ref( zSet );
        Cudd_RecursiveDerefZdd( dd, zTemp );
        Cudd_RecursiveDerefZdd( dd, zCube );
    } 
    Cudd_RecursiveDerefZdd( dd, zSet );
    ABC_FREE( pMapVars2Nums );
    return p;
}
Extra_SymmInfo_t * Extra_SymmPairsCreateFromZdd ( DdManager * dd , DdNode * zPairs , DdNode * bSupp ) { int i ; int nSuppSize ; Extra_SymmInfo_t * p ; int * pMapVars2Nums ; DdNode * bTemp ; DdNode * zSet , * zCube , * zTemp ; int iVar1 , iVar2 ; nSuppSize = Extra_bddSuppSize ( dd , bSupp ) ; p = Extra_SymmPairsAllocate ( nSuppSize ) ; pMapVars2Nums = ABC_ALLOC ( int , dd -> size ) ; memset ( pMapVars2Nums , 0 , dd -> size * sizeof ( int ) ) ; p -> nVarsMax = dd -> size ; p -> nNodes = 0 ; for ( i = 0 , bTemp = bSupp ; bTemp != b1 ; bTemp = cuddT ( bTemp ) , i ++ ) { p -> pVars [ i ] = bTemp -> index ; pMapVars2Nums [ bTemp -> index ] = i ; } zSet = zPairs ; Cudd_Ref ( zSet ) ; while ( zSet != z0 ) { zCube = Extra_zddSelectOneSubset ( dd , zSet ) ; Cudd_Ref ( zCube ) ; assert ( cuddT ( cuddT ( zCube ) ) == z1 ) ; iVar1 = zCube -> index / 2 ; iVar2 = cuddT ( zCube ) -> index / 2 ; if ( pMapVars2Nums [ iVar1 ] < pMapVars2Nums [ iVar2 ] ) p -> pSymms [ pMapVars2Nums [ iVar1 ] ] [ pMapVars2Nums [ iVar2 ] ] = 1 ; else p -> pSymms [ pMapVars2Nums [ iVar2 ] ] [ pMapVars2Nums [ iVar1 ] ] = 1 ; p -> nSymms ++ ; zSet = Cudd_zddDiff ( dd , zTemp = zSet , zCube ) ; Cudd_Ref ( zSet ) ; Cudd_RecursiveDerefZdd ( dd , zTemp ) ; Cudd_RecursiveDerefZdd ( dd , zCube ) ; } Cudd_RecursiveDerefZdd ( dd , zSet ) ; ABC_FREE ( pMapVars2Nums ) ; return p ; }
Function
Synopsis    [Creates the symmetry information structure from ZDD.]
Function Synopsis [ Creates the symmetry information structure from ZDD . ]
// allocate and clean the storage for symmetry info // allocate the storage for the temporary map // assign the variables //  p->nNodes   = Cudd_DagSize( zPairs ); // write the symmetry info into the structure // get the next cube // add these two variables to the data structure // count the symmetric pairs // update the cuver and deref the cube // for each cube 