29static void Dec_GraphPrint_rec( FILE * pFile,
Dec_Graph_t * pGraph,
Dec_Node_t * pNode,
int fCompl,
char * pNamesIn[],
int * pPos,
int LitSizeMax );
30static int Dec_GraphPrintGetLeafName( FILE * pFile,
int iLeaf,
int fCompl,
char * pNamesIn[] );
31static void Dec_GraphPrintUpdatePos( FILE * pFile,
int * pPos,
int LitSizeMax );
32static int Dec_GraphPrintOutputName( FILE * pFile,
char * pNameOut );
52 int LitSizeMax, LitSizeCur,
Pos, i;
55 if ( pNamesIn == NULL )
58 pNamesIn = (
char **)vNamesIn->pArray;
60 if ( pNameOut == NULL )
65 for ( i = 0; i < Dec_GraphLeaveNum(pGraph); i++ )
67 LitSizeCur =
strlen(pNamesIn[i]);
68 if ( LitSizeMax < LitSizeCur )
69 LitSizeMax = LitSizeCur;
71 if ( LitSizeMax > 50 )
75 if ( Dec_GraphIsConst(pGraph) )
77 Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
78 fprintf( pFile,
"Constant %d", !Dec_GraphIsComplement(pGraph) );
80 else if ( Dec_GraphIsVar(pGraph) )
82 Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
83 Dec_GraphPrintGetLeafName( pFile, Dec_GraphVarInt(pGraph), Dec_GraphIsComplement(pGraph), pNamesIn );
87 Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
88 Dec_GraphPrint_rec( pFile, pGraph, Dec_GraphNodeLast(pGraph), Dec_GraphIsComplement(pGraph), pNamesIn, &
Pos, LitSizeMax );
90 fprintf( pFile,
"\n" );
110 pNode0 = Dec_GraphNode(pGraph, pNode->
eEdge0.Node);
111 pNode1 = Dec_GraphNode(pGraph, pNode->
eEdge1.Node);
112 if ( Dec_GraphNodeIsVar(pGraph, pNode) )
114 (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
120 Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->
fCompl0, pNamesIn, pPos, LitSizeMax );
123 fprintf( pFile,
"(" );
125 Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->
fCompl0, pNamesIn, pPos, LitSizeMax );
126 fprintf( pFile,
")" );
129 fprintf( pFile,
" " );
132 Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
135 Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->
fCompl1, pNamesIn, pPos, LitSizeMax );
138 fprintf( pFile,
"(" );
140 Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->
fCompl1, pNamesIn, pPos, LitSizeMax );
141 fprintf( pFile,
")" );
148 Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->
fCompl0, pNamesIn, pPos, LitSizeMax );
149 fprintf( pFile,
" + " );
152 Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
154 Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->
fCompl1, pNamesIn, pPos, LitSizeMax );
171void Dec_GraphPrint_rec( FILE * pFile,
Dec_Graph_t * pGraph,
Dec_Node_t * pNode,
int fCompl,
char * pNamesIn[],
int * pPos,
int LitSizeMax )
174 Dec_Node_t * pNode00, * pNode01, * pNode10, * pNode11;
175 pNode0 = Dec_GraphNode(pGraph, pNode->
eEdge0.Node);
176 pNode1 = Dec_GraphNode(pGraph, pNode->
eEdge1.Node);
177 if ( Dec_GraphNodeIsVar(pGraph, pNode) )
179 (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
182 if ( !Dec_GraphNodeIsVar(pGraph, pNode0) && !Dec_GraphNodeIsVar(pGraph, pNode1) )
184 pNode00 = Dec_GraphNode(pGraph, pNode0->
eEdge0.Node);
185 pNode01 = Dec_GraphNode(pGraph, pNode0->
eEdge1.Node);
186 pNode10 = Dec_GraphNode(pGraph, pNode1->
eEdge0.Node);
187 pNode11 = Dec_GraphNode(pGraph, pNode1->
eEdge1.Node);
188 if ( (pNode00 == pNode10 || pNode00 == pNode11) && (pNode01 == pNode10 || pNode01 == pNode11) )
190 fprintf( pFile,
"(" );
192 Dec_GraphPrint_rec( pFile, pGraph, pNode00, pNode00->
fCompl0, pNamesIn, pPos, LitSizeMax );
193 fprintf( pFile,
" # " );
195 Dec_GraphPrint_rec( pFile, pGraph, pNode01, pNode01->
fCompl1, pNamesIn, pPos, LitSizeMax );
196 fprintf( pFile,
")" );
203 fprintf( pFile,
"(" );
205 Dec_GraphPrint_rec( pFile, pGraph, pNode0, !pNode->
eEdge0.fCompl, pNamesIn, pPos, LitSizeMax );
206 fprintf( pFile,
" + " );
208 Dec_GraphPrint_rec( pFile, pGraph, pNode1, !pNode->
eEdge1.fCompl, pNamesIn, pPos, LitSizeMax );
209 fprintf( pFile,
")" );
214 fprintf( pFile,
"(" );
216 Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->
eEdge0.fCompl, pNamesIn, pPos, LitSizeMax );
217 Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->
eEdge1.fCompl, pNamesIn, pPos, LitSizeMax );
218 fprintf( pFile,
")" );
234int Dec_GraphPrintGetLeafName( FILE * pFile,
int iLeaf,
int fCompl,
char * pNamesIn[] )
236 static char Buffer[100];
237 sprintf( Buffer,
"%s%s", fCompl?
"!" :
"", pNamesIn[iLeaf] );
238 fprintf( pFile,
"%s", Buffer );
253void Dec_GraphPrintUpdatePos( FILE * pFile,
int * pPos,
int LitSizeMax )
256 if ( *pPos + LitSizeMax < 77 )
258 fprintf( pFile,
"\n" );
259 for ( i = 0; i < 10; i++ )
260 fprintf( pFile,
" " );
275int Dec_GraphPrintOutputName( FILE * pFile,
char * pNameOut )
277 if ( pNameOut == NULL )
279 fprintf( pFile,
"%6s = ", pNameOut );
ABC_DLL void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
ABC_DLL Vec_Ptr_t * Abc_NodeGetFakeNames(int nNames)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Dec_GraphPrint2_rec(FILE *pFile, Dec_Graph_t *pGraph, Dec_Node_t *pNode, int fCompl, char *pNamesIn[], int *pPos, int LitSizeMax)
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
struct Dec_Node_t_ Dec_Node_t
struct Dec_Graph_t_ Dec_Graph_t
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.