Date [Ver. 1.0. Started - December 16, 2006.]
27{
30 int i, j;
32 int iEntry;
33 int nHyperNodesNum = 0;
34
35 assert( Abc_NtkIsStrash( pNtk ) && Abc_NtkIsComb( pNtk ) );
36
37 FILE *pFHMetis = fopen( pFileName, "wb" );
38 Vec_Ptr_t *vHyperEdges = Vec_PtrAlloc( 1000 );
39 if ( pFHMetis == NULL )
40 {
41 fprintf( stdout, "Io_WriteHMetis(): Cannot open the output file \"%s\".\n", pFileName );
42 fclose( pFHMetis );
43 return;
44 }
45
46
47 if ( fVerbose )
48 {
49 Abc_Print( 1, "Writing hMetis file \"%s\" with %d nodes (%d pi, %d po, %d and nodes).\n", pFileName, Abc_NtkObjNum( pNtk ), Abc_NtkPiNum( pNtk ), Abc_NtkPoNum( pNtk ), Abc_NtkNodeNum( pNtk ) );
50 }
51
53 {
54 Vec_Int_t *vHyperEdgeEach = Vec_IntAlloc( 20 );
55
56 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pObj ) );
57
58 if ( !Abc_ObjIsCo( pObj ) )
59 {
61 {
62 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pFanout ) );
63 }
64 } else
65 {
66 if ( fSkipPo )
67 {
68 continue;
69 }
70 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( Abc_ObjFanin0( pObj ) ) );
71 }
72 Vec_PtrPush( vHyperEdges, vHyperEdgeEach );
73 }
74
75 nHyperNodesNum = Abc_NtkObjNum( pNtk );
76
77
78 if ( fWeightEdges )
79 {
80 fprintf( pFHMetis, "%d %d 1\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
81 } else
82 {
83 fprintf( pFHMetis, "%d %d\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
84 }
85
87 {
88 if ( fWeightEdges )
89 {
90 fprintf( pFHMetis, "%d ", Vec_IntSize( vHyperEdgeEachWrite ) );
91 }
92
94 {
95 if ( j == Vec_IntSize( vHyperEdgeEachWrite ) - 1 )
96 {
97 fprintf( pFHMetis, "%d", iEntry );
98 } else
99 {
100 fprintf( pFHMetis, "%d ", iEntry );
101 }
102 }
103 fprintf( pFHMetis, "\n" );
104 }
105
106 fprintf( pFHMetis,
"%%This file was written by ABC on %s\n",
Extra_TimeStamp() );
107 fprintf( pFHMetis, "%%For information about hMetis format, refer to %s\n", "https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf" );
108 Vec_PtrFreeFree( vHyperEdges );
109 fclose( pFHMetis );
110}
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
#define Abc_ObjForEachFanout(pObj, pFanout, i)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.