GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
misc-template.c
Go to the documentation of this file.
1 /* LIBDGL -- a Directed Graph Library implementation
2  * Copyright (C) 2002 Roberto Micarelli
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * best view with tabstop=4
21  */
22 
23 /*
24  * Edge Traversing
25  */
27 #if defined(_DGL_V1)
28  pGraph->iErrno = DGL_ERR_NotSupported;
29  return -pGraph->iErrno;
30 #else
31  if ( pGraph->Flags & DGL_GS_FLAT ) {
32  if ( pEP && pEP->pvAVL ) {
33  if ( (pT->pvAVLT = malloc( sizeof(struct avl_traverser) )) == NULL ) {
35  return -pGraph->iErrno;
36  }
37  avl_t_init( pT->pvAVLT , pEP->pvAVL );
38  pT->pnEdge = NULL;
39  pT->pEdgePrioritizer = pEP;
40  }
41  else {
42  pT->pvAVLT = NULL;
43  pT->pnEdge = NULL;
44  pT->pEdgePrioritizer = NULL;
45  }
46  }
47  else {
48  if ( (pT->pvAVLT = malloc( sizeof(struct avl_traverser) )) == NULL ) {
50  return -pGraph->iErrno;
51  }
52  if ( pEP && pEP->pvAVL ) {
53  avl_t_init( pT->pvAVLT , pEP->pvAVL );
54  pT->pnEdge = NULL;
55  pT->pEdgePrioritizer = pEP;
56  }
57  else {
58  avl_t_init( pT->pvAVLT , pGraph->pEdgeTree );
59  pT->pnEdge = NULL;
60  pT->pEdgePrioritizer = NULL;
61  }
62  }
63  pT->pGraph = pGraph;
64  return 0;
65 #endif
66 }
67 
69 #if defined(_DGL_V1)
71 #else
72  if ( pT->pvAVLT ) free( pT->pvAVLT );
73  pT->pvAVLT = NULL;
74  pT->pnEdge = NULL;
75  pT->pEdgePrioritizer = NULL;
76 #endif
77 }
78 
80 #if defined(_DGL_V1)
82  return NULL;
83 #else
84  dglGraph_s * pG = pT->pGraph;
85 
86  pT->pnEdge = NULL;
87  if ( pT->pvAVLT && pT->pEdgePrioritizer ) {
89  dglTreeEdgePri32_s * pItem;
90 
91  pItem = avl_t_first( pT->pvAVLT, pPri->pvAVL );
92  if ( pItem ) {
93 /*
94 printf("edge_t_first: cEdge=%ld\n", pItem->cnData);
95 */
96  pPri->cEdge = pItem->cnData;
97  pPri->iEdge = 0;
98  if ( pPri->iEdge < pPri->cEdge ) {
99  pT->pnEdge = DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
100  pPri->iEdge++;
101  }
102  }
103  pPri->pEdgePri32Item = pItem;
104  }
105  else if ( pT->pvAVLT ) {
106  dglTreeEdge_s * pEdgeItem;
107 
108  if ( (pEdgeItem = avl_t_first( pT->pvAVLT, pG->pEdgeTree )) == NULL ) {
109  pT->pnEdge = NULL;
110  }
111  else {
112  pT->pnEdge = pEdgeItem->pv;
113  }
114  }
115  else {
116  if ( pG->cEdge > 0 ) pT->pnEdge = (dglInt32_t*)pG->pEdgeBuffer;
117  else pT->pnEdge = NULL;
118  }
119  return pT->pnEdge;
120 #endif
121 }
122 
124 {
125 #if defined(_DGL_V1)
127  return NULL;
128 #else
129  dglGraph_s * pG = pT->pGraph;
130 
131  pT->pnEdge = NULL;
132 
133  if ( pT->pvAVLT && pT->pEdgePrioritizer ) {
135  dglTreeEdgePri32_s * pItem = pPri->pEdgePri32Item;
136 
137  if (pItem && pPri->iEdge < pPri->cEdge) {
138  pT->pnEdge = DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
139  pPri->iEdge++;
140  }
141  else {
142  if ( (pItem = avl_t_next(pT->pvAVLT)) != NULL ) {
143  pPri->cEdge = pItem->cnData;
144  pPri->iEdge = 0;
145  if ( pPri->iEdge < pPri->cEdge ) {
146  pT->pnEdge = DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
147  pPri->iEdge++;
148  }
149  }
150  pPri->pEdgePri32Item = pItem;
151  }
152  }
153  else if ( pT->pvAVLT ) {
154  dglTreeEdge_s * pItem;
155 
156  if ( (pItem = avl_t_next( pT->pvAVLT )) != NULL ) {
157  pT->pnEdge = pItem->pv;
158  }
159  }
160  else {
161  pT->pnEdge += DGL_NODE_WSIZE( pG->EdgeAttrSize);
162  if (pT->pnEdge >= (dglInt32_t*)(pG->pEdgeBuffer + pG->iEdgeBuffer) ) {
163  pT->pnEdge = NULL;
164  }
165  }
166  return pT->pnEdge;
167 #endif
168 }
169 
170 
171 /*
172  * Node Traversing
173  */
175  if ( pGraph->Flags & DGL_GS_FLAT ) {
176  pT->pnNode = NULL;
177  pT->pvAVLT = NULL;
178  }
179  else {
180  if ( (pT->pvAVLT = malloc( sizeof(struct avl_traverser) )) == NULL ) {
182  return -pGraph->iErrno;
183  }
184  avl_t_init( pT->pvAVLT , pGraph->pNodeTree );
185  pT->pnNode = NULL;
186  }
187  pT->pGraph = pGraph;
188  return 0;
189 }
190 
192  if ( pT->pvAVLT ) free( pT->pvAVLT );
193  pT->pvAVLT = NULL;
194  pT->pnNode = NULL;
195 }
196 
198 {
199  DGL_T_NODEITEM_TYPE * pNodeItem;
200 
201  if ( pT->pvAVLT ) {
202  if ( (pNodeItem = avl_t_first( pT->pvAVLT, pT->pGraph->pNodeTree )) == NULL )
203  pT->pnNode = NULL;
204  else
205  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
206  }
207  else {
208  if ( pT->pGraph->cNode > 0 ) pT->pnNode = (dglInt32_t*)pT->pGraph->pNodeBuffer;
209  else pT->pnNode = NULL;
210  }
211  return pT->pnNode;
212 }
213 
215 {
216  DGL_T_NODEITEM_TYPE * pNodeItem;
217 
218  if ( pT->pvAVLT ) {
219  if ( (pNodeItem = avl_t_next( pT->pvAVLT )) == NULL )
220  pT->pnNode = NULL;
221  else
222  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
223  }
224  else {
225  pT->pnNode += DGL_NODE_WSIZE( pT->pGraph->NodeAttrSize );
226  if ( pT->pnNode >= (dglInt32_t*)(pT->pGraph->pNodeBuffer + pT->pGraph->iNodeBuffer) ) pT->pnNode = NULL;
227  }
228  return pT->pnNode;
229 }
230 
232 {
233  DGL_T_NODEITEM_TYPE * pNodeItem , findItem;
234 
235  if ( pT->pvAVLT ) {
236  findItem.nKey = nNodeId;
237  if ( (pNodeItem = avl_t_find( pT->pvAVLT , pT->pGraph->pNodeTree , &findItem )) == NULL )
238  pT->pnNode = NULL;
239  else
240  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
241  }
242  else {
243  pT->pnNode = DGL_GET_NODE_FUNC(pT->pGraph, nNodeId);
244  }
245  return pT->pnNode;
246 }
247 
248 
249 /*
250  * Edgeset Traversing
251  */
253  dglGraph_s * pGraph ,
254  dglEdgesetTraverser_s * pT ,
255  dglInt32_t * pnEdgeset
256  )
257 {
258  pT->pGraph = pGraph;
259  pT->pnEdgeset = pnEdgeset;
260  pT->cEdge = (pnEdgeset)?*pnEdgeset:0;
261  pT->iEdge = 0;
262  return 0;
263 }
264 
265 
267 {
268 }
269 
271 {
272 #if defined(_DGL_V2)
273  dglInt32_t * pnOffset;
274  dglTreeEdge_s * pEdgeItem, EdgeItem;
275 #endif
276 
277  if ( pT->cEdge == 0 ) return NULL;
278  pT->iEdge = 1;
279 #if defined(_DGL_V1)
280  return pT->pnEdgeset + 1;
281 #endif
282 #if defined(_DGL_V2)
283  pnOffset = pT->pnEdgeset + 1;
284  if ( pT->pGraph->Flags & DGL_GS_FLAT ) {
285  pT->pvCurrentItem = NULL;
286  return DGL_EDGEBUFFER_SHIFT(pT->pGraph, *pnOffset);
287  }
288  else {
289  EdgeItem.nKey = *pnOffset;
290  if ( (pEdgeItem = avl_find( pT->pGraph->pEdgeTree, &EdgeItem )) != NULL) {
291  pT->pvCurrentItem = pEdgeItem;
292  return pEdgeItem->pv;
293  }
294  }
295 #endif
296  return NULL;
297 }
298 
299 
301 {
302 #if defined(_DGL_V2)
303  dglInt32_t * pnOffset;
304  dglTreeEdge_s * pEdgeItem, EdgeItem;
305 #endif
306 
307  if ( pT->cEdge > 0 && pT->iEdge < pT->cEdge ) {
308 #if defined(_DGL_V1)
309  return DGL_EDGESET_EDGE_PTR(pT->pnEdgeset, pT->iEdge++, pT->pGraph->EdgeAttrSize);
310 #endif
311 #if defined(_DGL_V2)
312  pnOffset = pT->pnEdgeset + 1 + pT->iEdge++;
313  if ( pT->pGraph->Flags & DGL_GS_FLAT ) {
314  return DGL_EDGEBUFFER_SHIFT(pT->pGraph, *pnOffset);
315  }
316  else {
317  EdgeItem.nKey = *pnOffset;
318  if ( (pEdgeItem = avl_find( pT->pGraph->pEdgeTree, &EdgeItem )) != NULL) {
319  pT->pvCurrentItem = pEdgeItem;
320  return pEdgeItem->pv;
321  }
322  }
323 #endif
324  }
325  return NULL;
326 }
327 
328 
329 /*
330  * Flatten the graph
331  */
333 {
334  register DGL_T_NODEITEM_TYPE * ptreenode;
335 #if defined(_DGL_V2)
336  register dglTreeEdge_s * ptreeEdge;
337  int i;
338 #endif
339  register dglInt32_t * pEdge;
340  register dglInt32_t * pnode;
341  register dglInt32_t * pnodescan;
342  dglInt32_t * pOutEdgeset;
343  dglInt32_t * pInEdgeset;
344  int cOutEdgeset;
345  int cInEdgeset;
346 
347  struct avl_traverser avlTraverser;
348 
349  if ( pgraph->Flags & DGL_GS_FLAT )
350  {
351  pgraph->iErrno = DGL_ERR_BadOnFlatGraph;
352  return -pgraph->iErrno;
353  }
354 
355  pgraph->pNodeBuffer = NULL; /* should be already */
356  pgraph->iNodeBuffer = 0;
357  pgraph->pEdgeBuffer = NULL;
358  pgraph->iEdgeBuffer = 0;
359 
360 
361 #if defined(_DGL_V2)
362 /*
363 printf("flatten: traversing edges\n");
364 */
365  avl_t_init( & avlTraverser, pgraph->pEdgeTree );
366 
367  for (
368  ptreeEdge = avl_t_first( & avlTraverser , pgraph->pEdgeTree ) ;
369  ptreeEdge ;
370  ptreeEdge = avl_t_next( & avlTraverser )
371  )
372  {
373  pEdge = ptreeEdge->pv;
374 
375 /*
376 printf( "flatten: add edge %ld to edge buffer\n", DGL_EDGE_ID(pEdge) );
377 */
378 
379  pgraph->pEdgeBuffer = realloc(
380  pgraph->pEdgeBuffer ,
381  pgraph->iEdgeBuffer + DGL_EDGE_SIZEOF(pgraph->EdgeAttrSize)
382  );
383 
384  if ( pgraph->pEdgeBuffer == NULL ) {
386  return -pgraph->iErrno;
387  }
388 
389  memcpy( pgraph->pEdgeBuffer + pgraph->iEdgeBuffer, pEdge, DGL_EDGE_SIZEOF(pgraph->EdgeAttrSize) );
390 
391  pgraph->iEdgeBuffer += DGL_EDGE_SIZEOF(pgraph->EdgeAttrSize);
392  }
393 #endif
394 
395 /*
396 printf("flatten: traversing nodes\n");
397 */
398  avl_t_init( & avlTraverser, pgraph->pNodeTree );
399 
400  for (
401  ptreenode = avl_t_first( & avlTraverser , pgraph->pNodeTree ) ;
402  ptreenode ;
403  ptreenode = avl_t_next( & avlTraverser )
404  )
405  {
406  pnode = DGL_T_NODEITEM_NodePTR(ptreenode);
407  pOutEdgeset = DGL_T_NODEITEM_OutEdgesetPTR(ptreenode);
408  pInEdgeset = DGL_T_NODEITEM_InEdgesetPTR(ptreenode);
409 
410  if ( !(DGL_NODE_STATUS(pnode) & DGL_NS_ALONE) )
411  {
412  cOutEdgeset = (pOutEdgeset) ?
413  DGL_EDGESET_SIZEOF(DGL_EDGESET_EDGECOUNT(pOutEdgeset), pgraph->EdgeAttrSize) :
414  sizeof(dglInt32_t);
415 
416 #if !defined(_DGL_V1)
417  cInEdgeset = (pInEdgeset) ?
419  sizeof(dglInt32_t);
420 #else
421  cInEdgeset = 0;
422 #endif
423 
424  pgraph->pEdgeBuffer = realloc( pgraph->pEdgeBuffer ,
425  pgraph->iEdgeBuffer + cOutEdgeset + cInEdgeset );
426 
427  if ( pgraph->pEdgeBuffer == NULL )
428  {
430  return -pgraph->iErrno;
431  }
432 
433  {
434  dglInt32_t nDummy = 0;
435 
436  memcpy( pgraph->pEdgeBuffer + pgraph->iEdgeBuffer , (pOutEdgeset)?pOutEdgeset:&nDummy , cOutEdgeset );
437 #if !defined(_DGL_V1)
438  memcpy( pgraph->pEdgeBuffer + pgraph->iEdgeBuffer + cOutEdgeset , (pInEdgeset)?pInEdgeset:&nDummy, cInEdgeset );
439 #endif
440  }
441 
442  DGL_NODE_EDGESET_OFFSET(pnode) = pgraph->iEdgeBuffer;
443 
444  pgraph->iEdgeBuffer += cOutEdgeset + cInEdgeset;
445  }
446 
447  pgraph->pNodeBuffer = realloc(pgraph->pNodeBuffer, pgraph->iNodeBuffer + DGL_NODE_SIZEOF(pgraph->NodeAttrSize));
448 
449  if ( pgraph->pNodeBuffer == NULL )
450  {
452  return -pgraph->iErrno;
453  }
454 
455  memcpy( pgraph->pNodeBuffer + pgraph->iNodeBuffer , pnode , DGL_NODE_SIZEOF(pgraph->NodeAttrSize) );
456  pgraph->iNodeBuffer += DGL_NODE_SIZEOF(pgraph->NodeAttrSize);
457  }
458 
459 #if defined(_DGL_V2)
460  if ( pgraph->pEdgeTree ) {
462  pgraph->pEdgeTree = NULL;
463  }
464 #endif
465 
466  if ( pgraph->pNodeTree ) {
468  pgraph->pNodeTree = NULL;
469  }
470 
471  pgraph->Flags |= DGL_GS_FLAT; /* flattened */
472 
473  /*
474  * convert node-id to node-offset
475  */
476  DGL_FOREACH_NODE(pgraph, pnodescan)
477  {
478  if ( !(DGL_NODE_STATUS(pnodescan) & DGL_NS_ALONE) )
479  {
480  pOutEdgeset = DGL_EDGEBUFFER_SHIFT(pgraph, DGL_NODE_EDGESET_OFFSET(pnodescan));
481 
482 #if defined(_DGL_V2)
483  for( i = 0 ; i < pOutEdgeset[0] ; i ++ ) {
484 /*
485 printf("flatten: node %ld: scan out edge %ld/%ld - %ld\n", DGL_NODE_ID(pnodescan), i+1, pOutEdgeset[0], pOutEdgeset[i+1]);
486 */
487  pEdge = DGL_GET_EDGE_FUNC(pgraph, pOutEdgeset[i+1]);
488  if (pEdge == NULL) {
490  return -pgraph->iErrno;
491  }
492  /*
493 printf(" retrieved id %ld\n", DGL_EDGE_ID(pEdge) );
494 */
495  pOutEdgeset[i+1] = DGL_EDGEBUFFER_OFFSET(pgraph,pEdge);
496  }
497 
498  pInEdgeset = pOutEdgeset + pOutEdgeset[0] + 1;
499 
500  for( i = 0 ; i < pInEdgeset[0] ; i ++ ) {
501  /*
502 printf("flatten: node %ld: scan in edge %ld/%ld - %ld\n",
503  DGL_NODE_ID(pnodescan), i+1, pInEdgeset[0], pInEdgeset[i+1]);
504  */
505  pEdge = DGL_GET_EDGE_FUNC(pgraph, pInEdgeset[i+1]);
506  if (pEdge == NULL) {
508  return -pgraph->iErrno;
509  }
510  /*
511 printf(" retrieved id %ld\n", DGL_EDGE_ID(pEdge) );
512 */
513  pInEdgeset[i+1] = DGL_EDGEBUFFER_OFFSET(pgraph,pEdge);
514  }
515 #endif
516 
517 #if defined(_DGL_V2)
518  {
519  int iEdge;
520  DGL_FOREACH_EDGE(pgraph, pOutEdgeset, pEdge, iEdge)
521 #else
522  DGL_FOREACH_EDGE(pgraph, pOutEdgeset, pEdge)
523 #endif
524  {
525  if ( (pnode = DGL_GET_NODE_FUNC( pgraph, DGL_EDGE_HEADNODE_OFFSET(pEdge))) == NULL )
526  {
528  return -pgraph->iErrno;
529  }
530  DGL_EDGE_HEADNODE_OFFSET(pEdge) = DGL_NODEBUFFER_OFFSET(pgraph, pnode);
531 
532  if ( (pnode = DGL_GET_NODE_FUNC( pgraph , DGL_EDGE_TAILNODE_OFFSET(pEdge))) == NULL )
533  {
535  return -pgraph->iErrno;
536  }
537  DGL_EDGE_TAILNODE_OFFSET(pEdge) = DGL_NODEBUFFER_OFFSET(pgraph, pnode);
538  }
539 #if defined(_DGL_V2)
540  }
541 #endif
542  }
543  }
544 
545  return 0;
546 }
547 
548 
550 {
551  register dglInt32_t * pHead;
552  register dglInt32_t * pTail;
553  register dglInt32_t * pEdge;
554  register dglInt32_t * pEdgeset;
555  int nret;
556 
557  if ( ! (pgraph->Flags & DGL_GS_FLAT) )
558  {
559  pgraph->iErrno = DGL_ERR_BadOnTreeGraph;
560  return -pgraph->iErrno;
561  }
562 
563  /*
564  * unflag it now to avoid DGL_ADD_EDGE_FUNC() failure
565  */
566  pgraph->Flags &= ~DGL_GS_FLAT;
567  pgraph->cNode = 0;
568  pgraph->cEdge = 0;
569  pgraph->cHead = 0;
570  pgraph->cTail = 0;
571  pgraph->cAlone = 0;
572  pgraph->nnCost = (dglInt64_t)0;
573 
575  if ( pgraph->pNodeTree == NULL ) {
577  return -pgraph->iErrno;
578  }
579 #if defined(_DGL_V1)
580  pgraph->pEdgeTree = NULL;
581 #else
582  if ( pgraph->pEdgeTree == NULL ) pgraph->pEdgeTree = avl_create( dglTreeEdgeCompare, NULL, dglTreeGetAllocator() );
583  if ( pgraph->pEdgeTree == NULL ) {
585  return -pgraph->iErrno;
586  }
587 #endif
588 
589  DGL_FOREACH_NODE(pgraph,pHead)
590  {
591  if ( DGL_NODE_STATUS(pHead) & DGL_NS_HEAD )
592  {
593  pEdgeset = DGL_EDGEBUFFER_SHIFT(pgraph, DGL_NODE_EDGESET_OFFSET(pHead));
594 
595 #if defined(_DGL_V2)
596  {
597  int iEdge;
598  DGL_FOREACH_EDGE(pgraph, pEdgeset, pEdge, iEdge)
599 #else
600  DGL_FOREACH_EDGE(pgraph, pEdgeset, pEdge)
601 #endif
602  {
603  pTail = DGL_NODEBUFFER_SHIFT(pgraph, DGL_EDGE_TAILNODE_OFFSET(pEdge));
604 
605  nret = DGL_ADD_EDGE_FUNC( pgraph,
606  DGL_NODE_ID(pHead),
607  DGL_NODE_ID(pTail),
608  DGL_EDGE_COST(pEdge),
609  DGL_EDGE_ID(pEdge),
610  DGL_NODE_ATTR_PTR(pHead),
611  DGL_NODE_ATTR_PTR(pTail),
612  DGL_EDGE_ATTR_PTR(pEdge),
613  0 );
614 
615  if ( nret < 0 ) {
616  goto error;
617  }
618  }
619 #if defined(_DGL_V2)
620  }
621 #endif
622  }
623  else if ( DGL_NODE_STATUS(pHead) & DGL_NS_ALONE ) {
624  nret = DGL_ADD_NODE_FUNC( pgraph,
625  DGL_NODE_ID(pHead),
626  DGL_NODE_ATTR_PTR(pHead),
627  0 );
628  if ( nret < 0 ) {
629  goto error;
630  }
631  }
632  }
633 
634  /* move away flat-state data
635  */
636  if ( pgraph->pNodeBuffer ) free( pgraph->pNodeBuffer );
637  if ( pgraph->pEdgeBuffer ) free( pgraph->pEdgeBuffer );
638  pgraph->pNodeBuffer = NULL;
639  pgraph->pEdgeBuffer = NULL;
640  return 0;
641 
642 error:
643  if ( pgraph->pNodeTree ) avl_destroy( pgraph->pNodeTree, dglTreeNodeCancel );
644  if ( pgraph->pEdgeTree ) avl_destroy( pgraph->pEdgeTree, dglTreeEdgeCancel );
645  pgraph->pNodeTree = NULL;
646  pgraph->pEdgeTree = NULL;
647  pgraph->Flags |= DGL_GS_FLAT;
648  return nret;
649 }
650 
int dglTreeEdgeCompare(const void *pvEdgeA, const void *pvEdgeB, void *pvParam)
Definition: tree.c:162
dglGraph_s * pGraph
Definition: graph.h:271
dglInt32_t cEdge
Definition: graph.h:166
#define DGL_NS_HEAD
Definition: graph.h:60
#define DGL_NODE_ATTR_PTR
Definition: v1-defs.h:127
dglInt64_t nnCost
Definition: graph.h:167
dglInt32_t Flags
Definition: graph.h:169
int DGL_EDGESET_T_INITIALIZE_FUNC(dglGraph_s *pGraph, dglEdgesetTraverser_s *pT, dglInt32_t *pnEdgeset)
void DGL_EDGE_T_RELEASE_FUNC(dglEdgeTraverser_s *pT)
Definition: misc-template.c:68
dglInt32_t * pnData
Definition: tree.h:164
int DGL_ADD_EDGE_FUNC(dglGraph_s *pgraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge, void *pvHeadAttr, void *pvTailAttr, void *pvEdgeAttr, dglInt32_t nFlags)
dglInt32_t * DGL_NODE_T_NEXT_FUNC(dglNodeTraverser_s *pT)
dglInt32_t * DGL_EDGE_T_NEXT_FUNC(dglEdgeTraverser_s *pT)
#define DGL_EDGE_COST
Definition: v1-defs.h:136
void dglTreeNodeCancel(void *pvNode, void *pvParam)
Definition: tree.c:44
void dglTreeEdgeCancel(void *pvEdge, void *pvParam)
Definition: tree.c:155
#define avl_destroy
Definition: tree.h:36
#define DGL_T_NODEITEM_NodePTR(p)
Definition: v1-defs.h:169
#define avl_find
Definition: tree.h:41
#define DGL_EDGESET_SIZEOF
Definition: v1-defs.h:151
dglInt32_t NodeAttrSize
Definition: graph.h:158
dglInt32_t * DGL_EDGE_T_FIRST_FUNC(dglEdgeTraverser_s *pT)
Definition: misc-template.c:79
#define DGL_EDGEBUFFER_SHIFT
Definition: v1-defs.h:158
dglInt32_t * pnEdge
Definition: graph.h:273
#define avl_t_find
Definition: tree.h:47
int DGL_UNFLATTEN_FUNC(dglGraph_s *pgraph)
dglInt32_t iEdgeBuffer
Definition: graph.h:178
int DGL_EDGE_T_INITIALIZE_FUNC(dglGraph_s *pGraph, dglEdgeTraverser_s *pT, dglEdgePrioritizer_s *pEP)
Definition: misc-template.c:26
dglTreeEdgePri32_s * pEdgePri32Item
Definition: graph.h:144
void * pNodeTree
Definition: graph.h:173
#define DGL_NODE_STATUS
Definition: v1-defs.h:125
void * pvAVLT
Definition: graph.h:272
#define DGL_EDGE_ID
Definition: v1-defs.h:137
#define DGL_T_NODEITEM_Compare
Definition: v1-defs.h:175
#define DGL_T_NODEITEM_InEdgesetPTR(p)
Definition: v1-defs.h:173
#define DGL_T_NODEITEM_TYPE
Definition: v1-defs.h:168
#define DGL_ERR_HeadNodeNotFound
Definition: graph.h:290
dglInt32_t * pnNode
Definition: graph.h:252
#define avl_t_first
Definition: tree.h:45
#define DGL_EDGEBUFFER_OFFSET
Definition: v1-defs.h:159
dglInt32_t cNode
Definition: graph.h:162
dglGraph_s * pGraph
Definition: graph.h:260
#define DGL_NODEBUFFER_OFFSET
Definition: v1-defs.h:157
int iErrno
Definition: graph.h:154
int DGL_FLATTEN_FUNC(dglGraph_s *pgraph)
#define DGL_GS_FLAT
Definition: graph.h:36
dglInt32_t * pnEdgeset
Definition: graph.h:261
dglInt32_t cTail
Definition: graph.h:164
#define DGL_EDGE_TAILNODE_OFFSET
Definition: v1-defs.h:140
void * pvAVLT
Definition: graph.h:251
void * malloc(YYSIZE_T)
dglInt32_t * DGL_GET_NODE_FUNC(dglGraph_s *pgraph, dglInt32_t nodeid)
#define DGL_ERR_NotSupported
Definition: graph.h:288
#define DGL_NODEBUFFER_SHIFT
Definition: v1-defs.h:156
#define DGL_NODE_ID
Definition: v1-defs.h:126
#define avl_create
Definition: tree.h:34
#define DGL_EDGE_SIZEOF
Definition: v1-defs.h:133
#define DGL_ERR_MemoryExhausted
Definition: graph.h:283
dglInt32_t * DGL_NODE_T_FIND_FUNC(dglNodeTraverser_s *pT, dglInt32_t nNodeId)
#define DGL_T_NODEITEM_OutEdgesetPTR(p)
Definition: v1-defs.h:171
long long dglInt64_t
Definition: type.h:38
#define DGL_ERR_BadOnFlatGraph
Definition: graph.h:293
long dglInt32_t
Definition: type.h:37
void * dglTreeGetAllocator()
Definition: tree.c:422
int DGL_NODE_T_INITIALIZE_FUNC(dglGraph_s *pGraph, dglNodeTraverser_s *pT)
#define DGL_ERR_TailNodeNotFound
Definition: graph.h:291
void * pEdgeTree
Definition: graph.h:174
dglInt32_t * DGL_GET_EDGE_FUNC(dglGraph_s *pgraph, dglInt32_t nEdge)
void * pv
Definition: tree.h:98
dglInt32_t cnData
Definition: tree.h:163
#define avl_t_next
Definition: tree.h:50
void * pvCurrentItem
Definition: graph.h:262
#define DGL_EDGESET_EDGECOUNT
Definition: v1-defs.h:147
#define DGL_NODE_WSIZE
Definition: v1-defs.h:124
dglGraph_s * pGraph
Definition: graph.h:250
dglInt32_t cAlone
Definition: graph.h:165
#define DGL_FOREACH_NODE
Definition: v1-defs.h:161
dglInt32_t cHead
Definition: graph.h:163
dglEdgePrioritizer_s * pEdgePrioritizer
Definition: graph.h:274
#define DGL_ERR_BadOnTreeGraph
Definition: graph.h:294
#define DGL_EDGE_ATTR_PTR
Definition: v1-defs.h:138
dglInt32_t nKey
Definition: tree.h:97
return NULL
Definition: dbfopen.c:1394
dglInt32_t * DGL_EDGESET_T_NEXT_FUNC(dglEdgesetTraverser_s *pT)
#define DGL_NODE_EDGESET_OFFSET
Definition: v1-defs.h:128
dglInt32_t * DGL_EDGESET_T_FIRST_FUNC(dglEdgesetTraverser_s *pT)
void DGL_NODE_T_RELEASE_FUNC(dglNodeTraverser_s *pT)
void free(void *)
#define DGL_EDGESET_EDGE_PTR
Definition: v1-defs.h:148
dglInt32_t EdgeAttrSize
Definition: graph.h:159
#define DGL_ERR_UnexpectedNullPointer
Definition: graph.h:297
#define DGL_NS_ALONE
Definition: graph.h:62
#define DGL_FOREACH_EDGE
Definition: v1-defs.h:162
dglInt32_t * DGL_NODE_T_FIRST_FUNC(dglNodeTraverser_s *pT)
dglInt32_t iNodeBuffer
Definition: graph.h:176
#define DGL_EDGE_HEADNODE_OFFSET
Definition: v1-defs.h:139
#define DGL_NODE_SIZEOF
Definition: v1-defs.h:123
dglByte_t * pEdgeBuffer
Definition: graph.h:177
int DGL_ADD_NODE_FUNC(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
#define avl_t_init
Definition: tree.h:44
dglByte_t * pNodeBuffer
Definition: graph.h:175
void DGL_EDGESET_T_RELEASE_FUNC(dglEdgesetTraverser_s *pT)