tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
net.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * net.h
4  *
5  * =============================================================================
6  *
7  * Copyright (C) Stanford University, 2006. All Rights Reserved.
8  * Author: Chi Cao Minh
9  *
10  * =============================================================================
11  *
12  * For the license of bayes/sort.h and bayes/sort.c, please see the header
13  * of the files.
14  *
15  * ------------------------------------------------------------------------
16  *
17  * For the license of kmeans, please see kmeans/LICENSE.kmeans
18  *
19  * ------------------------------------------------------------------------
20  *
21  * For the license of ssca2, please see ssca2/COPYRIGHT
22  *
23  * ------------------------------------------------------------------------
24  *
25  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
26  * header of the files.
27  *
28  * ------------------------------------------------------------------------
29  *
30  * For the license of lib/rbtree.h and lib/rbtree.c, please see
31  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
32  *
33  * ------------------------------------------------------------------------
34  *
35  * Unless otherwise noted, the following license applies to STAMP files:
36  *
37  * Copyright (c) 2007, Stanford University
38  * All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions are
42  * met:
43  *
44  * * Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  *
47  * * Redistributions in binary form must reproduce the above copyright
48  * notice, this list of conditions and the following disclaimer in
49  * the documentation and/or other materials provided with the
50  * distribution.
51  *
52  * * Neither the name of Stanford University nor the names of its
53  * contributors may be used to endorse or promote products derived
54  * from this software without specific prior written permission.
55  *
56  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
57  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
60  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66  * THE POSSIBILITY OF SUCH DAMAGE.
67  *
68  * =============================================================================
69  */
70 
71 
72 #ifndef NET_H
73 #define NET_H 1
74 
75 
76 #include "bitmap.h"
77 #include "list.h"
78 #include "operation.h"
79 #include "queue.h"
80 #include "tm.h"
81 
82 typedef struct net net_t;
83 
84 
85 /* =============================================================================
86  * net_alloc
87  * =============================================================================
88  */
89 net_t*
90 net_alloc (long numNode);
91 
92 
93 /* =============================================================================
94  * net_free
95  * =============================================================================
96  */
97 void
98 net_free (net_t* netPtr);
99 
100 
101 /* =============================================================================
102  * net_applyOperation
103  * =============================================================================
104  */
105 void
106 net_applyOperation (net_t* netPtr, operation_t op, long fromId, long toId);
107 
108 
109 /* =============================================================================
110  * TMnet_applyOperation
111  * =============================================================================
112  */
113 void
115  net_t* netPtr, operation_t op, long fromId, long toId);
116 
117 
118 /* =============================================================================
119  * net_hasEdge
120  * =============================================================================
121  */
122 bool_t
123 net_hasEdge (net_t* netPtr, long fromId, long toId);
124 
125 
126 /* =============================================================================
127  * TMnet_hasEdge
128  * =============================================================================
129  */
130 bool_t
131 TMnet_hasEdge (TM_ARGDECL net_t* netPtr, long fromId, long toId);
132 
133 
134 /* =============================================================================
135  * net_isPath
136  * =============================================================================
137  */
138 bool_t
139 net_isPath (net_t* netPtr,
140  long fromId,
141  long toId,
142  bitmap_t* visitedBitmapPtr,
143  queue_t* workQueuePtr);
144 
145 
146 /* =============================================================================
147  * TMnet_isPath
148  * =============================================================================
149  */
150 bool_t
152  net_t* netPtr,
153  long fromId,
154  long toId,
155  bitmap_t* visitedBitmapPtr,
156  queue_t* workQueuePtr);
157 
158 
159 /* =============================================================================
160  * net_isCycle
161  * =============================================================================
162  */
163 bool_t
164 net_isCycle (net_t* netPtr);
165 
166 
167 /* =============================================================================
168  * net_getParentIdListPtr
169  * =============================================================================
170  */
171 list_t*
172 net_getParentIdListPtr (net_t* netPtr, long id);
173 
174 
175 /* =============================================================================
176  * net_getChildIdListPtr
177  * =============================================================================
178  */
179 list_t*
180 net_getChildIdListPtr (net_t* netPtr, long id);
181 
182 
183 /* =============================================================================
184  * net_findAncestors
185  * -- Contents of bitmapPtr set to 1 if parent, else 0
186  * -- Returns false if id is not root node (i.e., has cycle back id)
187  * =============================================================================
188  */
189 bool_t
190 net_findAncestors (net_t* netPtr,
191  long id,
192  bitmap_t* ancestorBitmapPtr,
193  queue_t* workQueuePtr);
194 
195 
196 /* =============================================================================
197  * TMnet_findAncestors
198  * -- Contents of bitmapPtr set to 1 if parent, else 0
199  * -- Returns false if id is not root node (i.e., has cycle back id)
200  * =============================================================================
201  */
202 bool_t
204  net_t* netPtr,
205  long id,
206  bitmap_t* ancestorBitmapPtr,
207  queue_t* workQueuePtr);
208 
209 
210 /* =============================================================================
211  * net_findDescendants
212  * -- Contents of bitmapPtr set to 1 if descendants, else 0
213  * -- Returns false if id is not root node (i.e., has cycle back id)
214  * =============================================================================
215  */
216 bool_t
217 net_findDescendants (net_t* netPtr,
218  long id,
219  bitmap_t* descendantBitmapPtr,
220  queue_t* workQueuePtr);
221 
222 
223 /* =============================================================================
224  * TMnet_findDescendants
225  * -- Contents of bitmapPtr set to 1 if descendants, else 0
226  * -- Returns false if id is not root node (i.e., has cycle back id)
227  * =============================================================================
228  */
229 bool_t
231  net_t* netPtr,
232  long id,
233  bitmap_t* descendantBitmapPtr,
234  queue_t* workQueuePtr);
235 
236 
237 /* =============================================================================
238  * net_generateRandomEdges
239  * =============================================================================
240  */
241 void
243  long maxNumParent,
244  long percentParent,
245  random_t* randomPtr);
246 
247 
248 #define TMNET_APPLYOPERATION(net, op, from, to) TMnet_applyOperation(TM_ARG \
249  net, \
250  op, \
251  from, \
252  to)
253 #define TMNET_HASEDGE(net, from, to) TMnet_hasEdge(TM_ARG \
254  net, \
255  from, \
256  to)
257 #define TMNET_ISPATH(net, from, to, bmp, wq) TMnet_isPath(TM_ARG \
258  net, \
259  from, \
260  to, \
261  bmp, \
262  wq)
263 #define TMNET_FINDANCESTORS(net, id, bmp, wq) TMnet_findAncestors(TM_ARG \
264  net, \
265  id, \
266  bmp, \
267  wq)
268 #define TMNET_FINDDESCENDANTS(net, id, bmp, wq) TMnet_findDescendants(TM_ARG \
269  net, \
270  id, \
271  bmp, \
272  wq)
273 
274 #endif /* NET_H */
275 
276 
277 /* =============================================================================
278  *
279  * End of net.h
280  *
281  * =============================================================================
282  */
void net_free(net_t *netPtr)
Definition: net.c:212
void net_generateRandomEdges(net_t *netPtr, long maxNumParent, long percentParent, random_t *randomPtr)
Definition: net.c:862
bool_t net_findAncestors(net_t *netPtr, long id, bitmap_t *ancestorBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:626
bool_t net_isPath(net_t *netPtr, long fromId, long toId, bitmap_t *visitedBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:425
void net_applyOperation(net_t *netPtr, operation_t op, long fromId, long toId)
Definition: net.c:342
net_t * net_alloc(long numNode)
Definition: net.c:174
Definition: queue.c:81
int bool_t
Definition: portable_defns.h:32
#define TM_ARGDECL
Definition: tm.h:532
void TMnet_applyOperation(TM_ARGDECL net_t *netPtr, operation_t op, long fromId, long toId)
Definition: net.c:359
bool_t TMnet_isPath(TM_ARGDECL net_t *netPtr, long fromId, long toId, bitmap_t *visitedBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:472
bool_t TMnet_hasEdge(TM_ARGDECL net_t *netPtr, long fromId, long toId)
Definition: net.c:401
Definition: bitmap.h:84
Definition: net.c:96
enum operation operation_t
bool_t net_hasEdge(net_t *netPtr, long fromId, long toId)
Definition: net.c:377
Definition: random.h:86
bool_t TMnet_findDescendants(TM_ARGDECL net_t *netPtr, long id, bitmap_t *descendantBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:804
list_t * net_getParentIdListPtr(net_t *netPtr, long id)
Definition: net.c:596
bool_t net_findDescendants(net_t *netPtr, long id, bitmap_t *descendantBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:745
list_t * net_getChildIdListPtr(net_t *netPtr, long id)
Definition: net.c:610
bool_t net_isCycle(net_t *netPtr)
Definition: net.c:557
Definition: list.h:93
bool_t TMnet_findAncestors(TM_ARGDECL net_t *netPtr, long id, bitmap_t *ancestorBitmapPtr, queue_t *workQueuePtr)
Definition: net.c:685