abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mtr.h
Go to the documentation of this file.
1 /**CHeaderFile*****************************************************************
2 
3  FileName [mtr.h]
4 
5  PackageName [mtr]
6 
7  Synopsis [Multiway-branch tree manipulation]
8 
9  Description [This package provides two layers of functions. Functions
10  of the lower level manipulate multiway-branch trees, implemented
11  according to the classical scheme whereby each node points to its
12  first child and its previous and next siblings. These functions are
13  collected in mtrBasic.c.<p>
14  Functions of the upper layer deal with group trees, that is the trees
15  used by group sifting to represent the grouping of variables. These
16  functions are collected in mtrGroup.c.]
17 
18  SeeAlso [The CUDD package documentation; specifically on group
19  sifting.]
20 
21  Author [Fabio Somenzi]
22 
23  Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
24 
25  All rights reserved.
26 
27  Redistribution and use in source and binary forms, with or without
28  modification, are permitted provided that the following conditions
29  are met:
30 
31  Redistributions of source code must retain the above copyright
32  notice, this list of conditions and the following disclaimer.
33 
34  Redistributions in binary form must reproduce the above copyright
35  notice, this list of conditions and the following disclaimer in the
36  documentation and/or other materials provided with the distribution.
37 
38  Neither the name of the University of Colorado nor the names of its
39  contributors may be used to endorse or promote products derived from
40  this software without specific prior written permission.
41 
42  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
52  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53  POSSIBILITY OF SUCH DAMAGE.]
54 
55  Revision [$Id: mtr.h,v 1.14 2009/02/20 02:03:47 fabio Exp $]
56 
57 ******************************************************************************/
58 
59 #ifndef ABC__bdd__mtr__mtr_h
60 #define ABC__bdd__mtr__mtr_h
61 
62 /*---------------------------------------------------------------------------*/
63 /* Nested includes */
64 /*---------------------------------------------------------------------------*/
65 
67 
68 /*---------------------------------------------------------------------------*/
69 /* Constant declarations */
70 /*---------------------------------------------------------------------------*/
71 
72 #ifndef SIZEOF_VOID_P
73 #define SIZEOF_VOID_P 4
74 #endif
75 #ifndef SIZEOF_INT
76 #define SIZEOF_INT 4
77 #endif
78 
79 //#undef CONST
80 //#if defined(__STDC__) || defined(__cplusplus)
81 //#define CONST const
82 //#else /* !(__STDC__ || __cplusplus) */
83 //#define CONST
84 //#endif /* !(__STDC__ || __cplusplus) */
85 
86 #if defined(__GNUC__)
87 #define MTR_INLINE __inline__
88 # if (__GNUC__ >2 || __GNUC_MINOR__ >=7)
89 # define MTR_UNUSED __attribute__ ((unused))
90 # else
91 # define MTR_UNUSED
92 # endif
93 #else
94 #define MTR_INLINE
95 #define MTR_UNUSED
96 #endif
97 
98 /* Flag definitions */
99 #define MTR_DEFAULT 0x00000000
100 #define MTR_TERMINAL 0x00000001
101 #define MTR_SOFT 0x00000002
102 #define MTR_FIXED 0x00000004
103 #define MTR_NEWNODE 0x00000008
104 
105 /* MTR_MAXHIGH is defined in such a way that on 32-bit and 64-bit
106 ** machines one can cast a value to (int) without generating a negative
107 ** number.
108 */
109 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
110 #define MTR_MAXHIGH (((MtrHalfWord) ~0) >> 1)
111 #else
112 #define MTR_MAXHIGH ((MtrHalfWord) ~0)
113 #endif
114 
115 
116 /*---------------------------------------------------------------------------*/
117 /* Stucture declarations */
118 /*---------------------------------------------------------------------------*/
119 
120 
121 /*---------------------------------------------------------------------------*/
122 /* Type declarations */
123 /*---------------------------------------------------------------------------*/
124 
125 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
126 typedef unsigned int MtrHalfWord;
127 #else
128 typedef unsigned short MtrHalfWord;
129 #endif
130 
131 typedef struct MtrNode {
136  struct MtrNode *parent;
137  struct MtrNode *child;
138  struct MtrNode *elder;
139  struct MtrNode *younger;
140 } MtrNode;
141 
142 
143 /*---------------------------------------------------------------------------*/
144 /* Variable declarations */
145 /*---------------------------------------------------------------------------*/
146 
147 
148 /*---------------------------------------------------------------------------*/
149 /* Macro declarations */
150 /*---------------------------------------------------------------------------*/
151 
152 /* Flag manipulation macros */
153 #define MTR_SET(node, flag) (node->flags |= (flag))
154 #define MTR_RESET(node, flag) (node->flags &= ~ (flag))
155 #define MTR_TEST(node, flag) (node->flags & (flag))
156 
157 
158 /**AutomaticStart*************************************************************/
159 
160 /*---------------------------------------------------------------------------*/
161 /* Function prototypes */
162 /*---------------------------------------------------------------------------*/
163 
164 extern MtrNode * Mtr_AllocNode (void);
165 extern void Mtr_DeallocNode (MtrNode *node);
166 extern MtrNode * Mtr_InitTree (void);
167 extern void Mtr_FreeTree (MtrNode *node);
168 extern MtrNode * Mtr_CopyTree (MtrNode *node, int expansion);
170 extern void Mtr_MakeLastChild (MtrNode *parent, MtrNode *child);
173 extern void Mtr_MakeNextSibling (MtrNode *first, MtrNode *second);
174 extern void Mtr_PrintTree (MtrNode *node);
175 extern MtrNode * Mtr_InitGroupTree (int lower, int size);
176 extern MtrNode * Mtr_MakeGroup (MtrNode *root, unsigned int low, unsigned int high, unsigned int flags);
177 extern MtrNode * Mtr_DissolveGroup (MtrNode *group);
178 extern MtrNode * Mtr_FindGroup (MtrNode *root, unsigned int low, unsigned int high);
179 extern int Mtr_SwapGroups (MtrNode *first, MtrNode *second);
180 extern void Mtr_PrintGroups (MtrNode *root, int silent);
181 extern MtrNode * Mtr_ReadGroups (FILE *fp, int nleaves);
182 
183 /**AutomaticEnd***************************************************************/
184 
186 
187 #endif /* __MTR */
MtrHalfWord flags
Definition: mtr.h:132
unsigned short MtrHalfWord
Definition: mtr.h:128
MtrHalfWord size
Definition: mtr.h:134
void Mtr_PrintTree(MtrNode *node)
Definition: mtrBasic.c:423
void Mtr_MakeLastChild(MtrNode *parent, MtrNode *child)
Definition: mtrBasic.c:300
struct MtrNode MtrNode
void Mtr_FreeTree(MtrNode *node)
Definition: mtrBasic.c:188
void Mtr_MakeNextSibling(MtrNode *first, MtrNode *second)
Definition: mtrBasic.c:395
struct MtrNode * parent
Definition: mtr.h:136
MtrNode * Mtr_DissolveGroup(MtrNode *group)
Definition: mtrGroup.c:357
struct MtrNode * elder
Definition: mtr.h:138
struct MtrNode * younger
Definition: mtr.h:139
MtrHalfWord index
Definition: mtr.h:135
MtrNode * Mtr_ReadGroups(FILE *fp, int nleaves)
Definition: mtrGroup.c:611
void Mtr_MakeFirstChild(MtrNode *parent, MtrNode *child)
Definition: mtrBasic.c:269
MtrNode * Mtr_AllocNode(void)
Definition: mtrBasic.c:118
static int size
Definition: cuddSign.c:86
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
MtrHalfWord low
Definition: mtr.h:133
MtrNode * Mtr_CreateFirstChild(MtrNode *parent)
Definition: mtrBasic.c:337
Definition: mtr.h:131
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
void Mtr_DeallocNode(MtrNode *node)
Definition: mtrBasic.c:140
void Mtr_PrintGroups(MtrNode *root, int silent)
Definition: mtrGroup.c:537
MtrNode * Mtr_InitGroupTree(int lower, int size)
Definition: mtrGroup.c:121
MtrNode * Mtr_InitTree(void)
Definition: mtrBasic.c:161
MtrNode * Mtr_CreateLastChild(MtrNode *parent)
Definition: mtrBasic.c:366
int Mtr_SwapGroups(MtrNode *first, MtrNode *second)
Definition: mtrGroup.c:470
MtrNode * Mtr_MakeGroup(MtrNode *root, unsigned int low, unsigned int high, unsigned int flags)
Definition: mtrGroup.c:158
MtrNode * Mtr_FindGroup(MtrNode *root, unsigned int low, unsigned int high)
Definition: mtrGroup.c:409
MtrNode * Mtr_CopyTree(MtrNode *node, int expansion)
Definition: mtrBasic.c:215
struct MtrNode * child
Definition: mtr.h:137