GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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  */
28 {
29 #if defined(_DGL_V1)
30  pGraph->iErrno = DGL_ERR_NotSupported;
31  return -pGraph->iErrno;
32 #else
33  if (pGraph->Flags & DGL_GS_FLAT) {
34  if (pEP && pEP->pvAVL) {
35  if ((pT->pvAVLT = malloc(sizeof(struct avl_traverser))) == NULL) {
37  return -pGraph->iErrno;
38  }
39  avl_t_init(pT->pvAVLT, pEP->pvAVL);
40  pT->pnEdge = NULL;
41  pT->pEdgePrioritizer = pEP;
42  }
43  else {
44  pT->pvAVLT = NULL;
45  pT->pnEdge = NULL;
46  pT->pEdgePrioritizer = NULL;
47  }
48  }
49  else {
50  if ((pT->pvAVLT = malloc(sizeof(struct avl_traverser))) == NULL) {
52  return -pGraph->iErrno;
53  }
54  if (pEP && pEP->pvAVL) {
55  avl_t_init(pT->pvAVLT, pEP->pvAVL);
56  pT->pnEdge = NULL;
57  pT->pEdgePrioritizer = pEP;
58  }
59  else {
60  avl_t_init(pT->pvAVLT, pGraph->pEdgeTree);
61  pT->pnEdge = NULL;
62  pT->pEdgePrioritizer = NULL;
63  }
64  }
65  pT->pGraph = pGraph;
66  return 0;
67 #endif
68 }
69 
71 {
72 #if defined(_DGL_V1)
74 #else
75  if (pT->pvAVLT)
76  free(pT->pvAVLT);
77  pT->pvAVLT = NULL;
78  pT->pnEdge = NULL;
79  pT->pEdgePrioritizer = NULL;
80 #endif
81 }
82 
84 {
85 #if defined(_DGL_V1)
87  return NULL;
88 #else
89  dglGraph_s *pG = pT->pGraph;
90 
91  pT->pnEdge = NULL;
92  if (pT->pvAVLT && pT->pEdgePrioritizer) {
94  dglTreeEdgePri32_s *pItem;
95 
96  pItem = avl_t_first(pT->pvAVLT, pPri->pvAVL);
97  if (pItem) {
98  /*
99  printf("edge_t_first: cEdge=%ld\n", pItem->cnData);
100  */
101  pPri->cEdge = pItem->cnData;
102  pPri->iEdge = 0;
103  if (pPri->iEdge < pPri->cEdge) {
104  pT->pnEdge =
105  DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
106  pPri->iEdge++;
107  }
108  }
109  pPri->pEdgePri32Item = pItem;
110  }
111  else if (pT->pvAVLT) {
112  dglTreeEdge_s *pEdgeItem;
113 
114  if ((pEdgeItem = avl_t_first(pT->pvAVLT, pG->pEdgeTree)) == NULL) {
115  pT->pnEdge = NULL;
116  }
117  else {
118  pT->pnEdge = pEdgeItem->pv;
119  }
120  }
121  else {
122  if (pG->cEdge > 0)
123  pT->pnEdge = (dglInt32_t *) pG->pEdgeBuffer;
124  else
125  pT->pnEdge = NULL;
126  }
127  return pT->pnEdge;
128 #endif
129 }
130 
132 {
133 #if defined(_DGL_V1)
135  return NULL;
136 #else
137  dglGraph_s *pG = pT->pGraph;
138 
139  pT->pnEdge = NULL;
140 
141  if (pT->pvAVLT && pT->pEdgePrioritizer) {
143  dglTreeEdgePri32_s *pItem = pPri->pEdgePri32Item;
144 
145  if (pItem && pPri->iEdge < pPri->cEdge) {
146  pT->pnEdge = DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
147  pPri->iEdge++;
148  }
149  else {
150  if ((pItem = avl_t_next(pT->pvAVLT)) != NULL) {
151  pPri->cEdge = pItem->cnData;
152  pPri->iEdge = 0;
153  if (pPri->iEdge < pPri->cEdge) {
154  pT->pnEdge =
155  DGL_GET_EDGE_FUNC(pG, pItem->pnData[pPri->iEdge]);
156  pPri->iEdge++;
157  }
158  }
159  pPri->pEdgePri32Item = pItem;
160  }
161  }
162  else if (pT->pvAVLT) {
163  dglTreeEdge_s *pItem;
164 
165  if ((pItem = avl_t_next(pT->pvAVLT)) != NULL) {
166  pT->pnEdge = pItem->pv;
167  }
168  }
169  else {
170  pT->pnEdge += DGL_NODE_WSIZE(pG->EdgeAttrSize);
171  if (pT->pnEdge >= (dglInt32_t *) (pG->pEdgeBuffer + pG->iEdgeBuffer)) {
172  pT->pnEdge = NULL;
173  }
174  }
175  return pT->pnEdge;
176 #endif
177 }
178 
179 
180 /*
181  * Node Traversing
182  */
184 {
185  if (pGraph->Flags & DGL_GS_FLAT) {
186  pT->pnNode = NULL;
187  pT->pvAVLT = NULL;
188  }
189  else {
190  if ((pT->pvAVLT = malloc(sizeof(struct avl_traverser))) == NULL) {
192  return -pGraph->iErrno;
193  }
194  avl_t_init(pT->pvAVLT, pGraph->pNodeTree);
195  pT->pnNode = NULL;
196  }
197  pT->pGraph = pGraph;
198  return 0;
199 }
200 
202 {
203  if (pT->pvAVLT)
204  free(pT->pvAVLT);
205  pT->pvAVLT = NULL;
206  pT->pnNode = NULL;
207 }
208 
210 {
211  DGL_T_NODEITEM_TYPE *pNodeItem;
212 
213  if (pT->pvAVLT) {
214  if ((pNodeItem =
215  avl_t_first(pT->pvAVLT, pT->pGraph->pNodeTree)) == NULL)
216  pT->pnNode = NULL;
217  else
218  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
219  }
220  else {
221  if (pT->pGraph->cNode > 0)
222  pT->pnNode = (dglInt32_t *) pT->pGraph->pNodeBuffer;
223  else
224  pT->pnNode = NULL;
225  }
226  return pT->pnNode;
227 }
228 
230 {
231  DGL_T_NODEITEM_TYPE *pNodeItem;
232 
233  if (pT->pvAVLT) {
234  if ((pNodeItem = avl_t_next(pT->pvAVLT)) == NULL)
235  pT->pnNode = NULL;
236  else
237  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
238  }
239  else {
241  if (pT->pnNode >=
242  (dglInt32_t *) (pT->pGraph->pNodeBuffer +
243  pT->pGraph->iNodeBuffer))
244  pT->pnNode = NULL;
245  }
246  return pT->pnNode;
247 }
248 
250 {
251  DGL_T_NODEITEM_TYPE *pNodeItem, findItem;
252 
253  if (pT->pvAVLT) {
254  findItem.nKey = nNodeId;
255  if ((pNodeItem =
256  avl_t_find(pT->pvAVLT, pT->pGraph->pNodeTree,
257  &findItem)) == NULL)
258  pT->pnNode = NULL;
259  else
260  pT->pnNode = DGL_T_NODEITEM_NodePTR(pNodeItem);
261  }
262  else {
263  pT->pnNode = DGL_GET_NODE_FUNC(pT->pGraph, nNodeId);
264  }
265  return pT->pnNode;
266 }
267 
268 
269 /*
270  * Edgeset Traversing
271  */
274  dglInt32_t * pnEdgeset)
275 {
276  pT->pGraph = pGraph;
277  pT->pnEdgeset = pnEdgeset;
278  pT->cEdge = (pnEdgeset) ? *pnEdgeset : 0;
279  pT->iEdge = 0;
280  return 0;
281 }
282 
283 
285 {
286 }
287 
289 {
290 #if defined(_DGL_V2)
291  dglInt32_t *pnOffset;
292  dglTreeEdge_s *pEdgeItem, EdgeItem;
293 #endif
294 
295  if (pT->cEdge == 0)
296  return NULL;
297  pT->iEdge = 1;
298 #if defined(_DGL_V1)
299  return pT->pnEdgeset + 1;
300 #endif
301 #if defined(_DGL_V2)
302  pnOffset = pT->pnEdgeset + 1;
303  if (pT->pGraph->Flags & DGL_GS_FLAT) {
304  pT->pvCurrentItem = NULL;
305  return DGL_EDGEBUFFER_SHIFT(pT->pGraph, *pnOffset);
306  }
307  else {
308  EdgeItem.nKey = *pnOffset;
309  if ((pEdgeItem = avl_find(pT->pGraph->pEdgeTree, &EdgeItem)) != NULL) {
310  pT->pvCurrentItem = pEdgeItem;
311  return pEdgeItem->pv;
312  }
313  }
314 #endif
315  return NULL;
316 }
317 
318 
320 {
321 #if defined(_DGL_V2)
322  dglInt32_t *pnOffset;
323  dglTreeEdge_s *pEdgeItem, EdgeItem;
324 #endif
325 
326  if (pT->cEdge > 0 && pT->iEdge < pT->cEdge) {
327 #if defined(_DGL_V1)
328  return DGL_EDGESET_EDGE_PTR(pT->pnEdgeset, pT->iEdge++,
329  pT->pGraph->EdgeAttrSize);
330 #endif
331 #if defined(_DGL_V2)
332  pnOffset = pT->pnEdgeset + 1 + pT->iEdge++;
333  if (pT->pGraph->Flags & DGL_GS_FLAT) {
334  return DGL_EDGEBUFFER_SHIFT(pT->pGraph, *pnOffset);
335  }
336  else {
337  EdgeItem.nKey = *pnOffset;
338  if ((pEdgeItem =
339  avl_find(pT->pGraph->pEdgeTree, &EdgeItem)) != NULL) {
340  pT->pvCurrentItem = pEdgeItem;
341  return pEdgeItem->pv;
342  }
343  }
344 #endif
345  }
346  return NULL;
347 }
348 
349 
350 /*
351  * Flatten the graph
352  */
354 {
355  register DGL_T_NODEITEM_TYPE *ptreenode;
356 
357 #if defined(_DGL_V2)
358  register dglTreeEdge_s *ptreeEdge;
359  int i;
360 #endif
361  register dglInt32_t *pEdge;
362  register dglInt32_t *pnode;
363  register dglInt32_t *pnodescan;
364  dglInt32_t *pOutEdgeset;
365  dglInt32_t *pInEdgeset;
366  int cOutEdgeset;
367  int cInEdgeset;
368 
369  struct avl_traverser avlTraverser;
370 
371  if (pgraph->Flags & DGL_GS_FLAT) {
372  pgraph->iErrno = DGL_ERR_BadOnFlatGraph;
373  return -pgraph->iErrno;
374  }
375 
376  pgraph->pNodeBuffer = NULL; /* should be already */
377  pgraph->iNodeBuffer = 0;
378  pgraph->pEdgeBuffer = NULL;
379  pgraph->iEdgeBuffer = 0;
380 
381 
382 #if defined(_DGL_V2)
383  /*
384  printf("flatten: traversing edges\n");
385  */
386  avl_t_init(&avlTraverser, pgraph->pEdgeTree);
387 
388  for (ptreeEdge = avl_t_first(&avlTraverser, pgraph->pEdgeTree);
389  ptreeEdge; ptreeEdge = avl_t_next(&avlTraverser)
390  ) {
391  pEdge = ptreeEdge->pv;
392 
393  /*
394  printf( "flatten: add edge %ld to edge buffer\n", DGL_EDGE_ID(pEdge) );
395  */
396 
397  pgraph->pEdgeBuffer = realloc(pgraph->pEdgeBuffer,
398  pgraph->iEdgeBuffer +
400  );
401 
402  if (pgraph->pEdgeBuffer == NULL) {
404  return -pgraph->iErrno;
405  }
406 
407  memcpy(pgraph->pEdgeBuffer + pgraph->iEdgeBuffer, pEdge,
408  DGL_EDGE_SIZEOF(pgraph->EdgeAttrSize));
409 
410  pgraph->iEdgeBuffer += DGL_EDGE_SIZEOF(pgraph->EdgeAttrSize);
411  }
412 #endif
413 
414  /*
415  printf("flatten: traversing nodes\n");
416  */
417  avl_t_init(&avlTraverser, pgraph->pNodeTree);
418 
419  for (ptreenode = avl_t_first(&avlTraverser, pgraph->pNodeTree);
420  ptreenode; ptreenode = avl_t_next(&avlTraverser)
421  ) {
422  pnode = DGL_T_NODEITEM_NodePTR(ptreenode);
423  pOutEdgeset = DGL_T_NODEITEM_OutEdgesetPTR(ptreenode);
424  pInEdgeset = DGL_T_NODEITEM_InEdgesetPTR(ptreenode);
425 
426  if (!(DGL_NODE_STATUS(pnode) & DGL_NS_ALONE)) {
427  cOutEdgeset = (pOutEdgeset) ?
429  pgraph->EdgeAttrSize) : sizeof(dglInt32_t);
430 
431 #if !defined(_DGL_V1)
432  cInEdgeset = (pInEdgeset) ?
434  pgraph->EdgeAttrSize) : sizeof(dglInt32_t);
435 #else
436  cInEdgeset = 0;
437 #endif
438 
439  pgraph->pEdgeBuffer = realloc(pgraph->pEdgeBuffer,
440  pgraph->iEdgeBuffer + cOutEdgeset +
441  cInEdgeset);
442 
443  if (pgraph->pEdgeBuffer == NULL) {
445  return -pgraph->iErrno;
446  }
447 
448  {
449  dglInt32_t nDummy = 0;
450 
451  memcpy(pgraph->pEdgeBuffer + pgraph->iEdgeBuffer,
452  (pOutEdgeset) ? pOutEdgeset : &nDummy, cOutEdgeset);
453 #if !defined(_DGL_V1)
454  memcpy(pgraph->pEdgeBuffer + pgraph->iEdgeBuffer +
455  cOutEdgeset, (pInEdgeset) ? pInEdgeset : &nDummy,
456  cInEdgeset);
457 #endif
458  }
459 
460  DGL_NODE_EDGESET_OFFSET(pnode) = pgraph->iEdgeBuffer;
461 
462  pgraph->iEdgeBuffer += cOutEdgeset + cInEdgeset;
463  }
464 
465  pgraph->pNodeBuffer =
466  realloc(pgraph->pNodeBuffer,
467  pgraph->iNodeBuffer +
468  DGL_NODE_SIZEOF(pgraph->NodeAttrSize));
469 
470  if (pgraph->pNodeBuffer == NULL) {
472  return -pgraph->iErrno;
473  }
474 
475  memcpy(pgraph->pNodeBuffer + pgraph->iNodeBuffer, pnode,
476  DGL_NODE_SIZEOF(pgraph->NodeAttrSize));
477  pgraph->iNodeBuffer += DGL_NODE_SIZEOF(pgraph->NodeAttrSize);
478  }
479 
480 #if defined(_DGL_V2)
481  if (pgraph->pEdgeTree) {
483  pgraph->pEdgeTree = NULL;
484  }
485 #endif
486 
487  if (pgraph->pNodeTree) {
489  pgraph->pNodeTree = NULL;
490  }
491 
492  pgraph->Flags |= DGL_GS_FLAT; /* flattened */
493 
494  /*
495  * convert node-id to node-offset
496  */
497  DGL_FOREACH_NODE(pgraph, pnodescan) {
498  if (!(DGL_NODE_STATUS(pnodescan) & DGL_NS_ALONE)) {
499  pOutEdgeset =
500  DGL_EDGEBUFFER_SHIFT(pgraph,
501  DGL_NODE_EDGESET_OFFSET(pnodescan));
502 
503 #if defined(_DGL_V2)
504  for (i = 0; i < pOutEdgeset[0]; i++) {
505  /*
506  printf("flatten: node %ld: scan out edge %ld/%ld - %ld\n", DGL_NODE_ID(pnodescan), i+1, pOutEdgeset[0], pOutEdgeset[i+1]);
507  */
508  pEdge = DGL_GET_EDGE_FUNC(pgraph, pOutEdgeset[i + 1]);
509  if (pEdge == NULL) {
511  return -pgraph->iErrno;
512  }
513  /*
514  printf(" retrieved id %ld\n", DGL_EDGE_ID(pEdge) );
515  */
516  pOutEdgeset[i + 1] = DGL_EDGEBUFFER_OFFSET(pgraph, pEdge);
517  }
518 
519  pInEdgeset = pOutEdgeset + pOutEdgeset[0] + 1;
520 
521  for (i = 0; i < pInEdgeset[0]; i++) {
522  /*
523  printf("flatten: node %ld: scan in edge %ld/%ld - %ld\n",
524  DGL_NODE_ID(pnodescan), i+1, pInEdgeset[0], pInEdgeset[i+1]);
525  */
526  pEdge = DGL_GET_EDGE_FUNC(pgraph, pInEdgeset[i + 1]);
527  if (pEdge == NULL) {
529  return -pgraph->iErrno;
530  }
531  /*
532  printf(" retrieved id %ld\n", DGL_EDGE_ID(pEdge) );
533  */
534  pInEdgeset[i + 1] = DGL_EDGEBUFFER_OFFSET(pgraph, pEdge);
535  }
536 #endif
537 
538 #if defined(_DGL_V2)
539  {
540  int iEdge;
541 
542  DGL_FOREACH_EDGE(pgraph, pOutEdgeset, pEdge, iEdge)
543 #else
544  DGL_FOREACH_EDGE(pgraph, pOutEdgeset, pEdge)
545 #endif
546  {
547  if ((pnode =
548  DGL_GET_NODE_FUNC(pgraph,
549  DGL_EDGE_HEADNODE_OFFSET(pEdge))) ==
550  NULL) {
552  return -pgraph->iErrno;
553  }
554  DGL_EDGE_HEADNODE_OFFSET(pEdge) =
555  DGL_NODEBUFFER_OFFSET(pgraph, pnode);
556 
557  if ((pnode =
558  DGL_GET_NODE_FUNC(pgraph,
559  DGL_EDGE_TAILNODE_OFFSET(pEdge))) ==
560  NULL) {
562  return -pgraph->iErrno;
563  }
564  DGL_EDGE_TAILNODE_OFFSET(pEdge) =
565  DGL_NODEBUFFER_OFFSET(pgraph, pnode);
566  }
567 #if defined(_DGL_V2)
568  }
569 #endif
570  }
571 }
572 
573 return 0;
574 }
575 
576 
578 {
579  register dglInt32_t *pHead;
580  register dglInt32_t *pTail;
581  register dglInt32_t *pEdge;
582  register dglInt32_t *pEdgeset;
583  int nret;
584 
585  if (!(pgraph->Flags & DGL_GS_FLAT)) {
586  pgraph->iErrno = DGL_ERR_BadOnTreeGraph;
587  return -pgraph->iErrno;
588  }
589 
590  /*
591  * unflag it now to avoid DGL_ADD_EDGE_FUNC() failure
592  */
593  pgraph->Flags &= ~DGL_GS_FLAT;
594  pgraph->cNode = 0;
595  pgraph->cEdge = 0;
596  pgraph->cHead = 0;
597  pgraph->cTail = 0;
598  pgraph->cAlone = 0;
599  pgraph->nnCost = (dglInt64_t) 0;
600 
601  if (pgraph->pNodeTree == NULL)
602  pgraph->pNodeTree =
604  if (pgraph->pNodeTree == NULL) {
606  return -pgraph->iErrno;
607  }
608 #if defined(_DGL_V1)
609  pgraph->pEdgeTree = NULL;
610 #else
611  if (pgraph->pEdgeTree == NULL)
612  pgraph->pEdgeTree =
614  if (pgraph->pEdgeTree == NULL) {
616  return -pgraph->iErrno;
617  }
618 #endif
619 
620  DGL_FOREACH_NODE(pgraph, pHead) {
621  if (DGL_NODE_STATUS(pHead) & DGL_NS_HEAD) {
622  pEdgeset =
624 
625 #if defined(_DGL_V2)
626  {
627  int iEdge;
628 
629  DGL_FOREACH_EDGE(pgraph, pEdgeset, pEdge, iEdge)
630 #else
631  DGL_FOREACH_EDGE(pgraph, pEdgeset, pEdge)
632 #endif
633  {
634  pTail =
635  DGL_NODEBUFFER_SHIFT(pgraph,
636  DGL_EDGE_TAILNODE_OFFSET(pEdge));
637 
638  nret = DGL_ADD_EDGE_FUNC(pgraph,
639  DGL_NODE_ID(pHead),
640  DGL_NODE_ID(pTail),
641  DGL_EDGE_COST(pEdge),
642  DGL_EDGE_ID(pEdge),
643  DGL_NODE_ATTR_PTR(pHead),
644  DGL_NODE_ATTR_PTR(pTail),
645  DGL_EDGE_ATTR_PTR(pEdge), 0);
646 
647  if (nret < 0) {
648  goto error;
649  }
650  }
651 #if defined(_DGL_V2)
652  }
653 #endif
654  }
655  else
656 if (DGL_NODE_STATUS(pHead) & DGL_NS_ALONE) {
657  nret = DGL_ADD_NODE_FUNC(pgraph,
658  DGL_NODE_ID(pHead), DGL_NODE_ATTR_PTR(pHead), 0);
659  if (nret < 0) {
660  goto error;
661  }
662 }
663 }
664 
665  /* move away flat-state data
666  */
667 if (pgraph->pNodeBuffer)
668  free(pgraph->pNodeBuffer);
669 if (pgraph->pEdgeBuffer)
670  free(pgraph->pEdgeBuffer);
671 pgraph->pNodeBuffer = NULL;
672 pgraph->pEdgeBuffer = NULL;
673 return 0;
674 
675 error:
676 if (pgraph->pNodeTree)
678 if (pgraph->pEdgeTree)
680 pgraph->pNodeTree = NULL;
681 pgraph->pEdgeTree = NULL;
682 pgraph->Flags |= DGL_GS_FLAT;
683 return nret;
684 }
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:70
dglInt32_t * pnData
Definition: tree.h:163
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:33
#define DGL_T_NODEITEM_NodePTR(p)
Definition: v1-defs.h:169
#define avl_find
Definition: tree.h:38
#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:83
#define DGL_EDGEBUFFER_SHIFT
Definition: v1-defs.h:158
dglInt32_t * pnEdge
Definition: graph.h:273
#define avl_t_find
Definition: tree.h:44
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
void free(void *)
#define NULL
Definition: ccmath.h:32
#define DGL_ERR_HeadNodeNotFound
Definition: graph.h:290
dglInt32_t * pnNode
Definition: graph.h:252
#define avl_t_first
Definition: tree.h:42
#define DGL_EDGEBUFFER_OFFSET
Definition: v1-defs.h:159
dglInt32_t cNode
Definition: graph.h:162
void * malloc(YYSIZE_T)
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
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:31
#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:97
dglInt32_t cnData
Definition: tree.h:162
#define avl_t_next
Definition: tree.h:47
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:96
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)
#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:41
dglByte_t * pNodeBuffer
Definition: graph.h:175
void DGL_EDGESET_T_RELEASE_FUNC(dglEdgesetTraverser_s *pT)