23 #ifndef _DGL_dglGraph_s_V2_H_
24 #define _DGL_dglGraph_s_V2_H_
33 #define DGL_IN_NODEID_v2 0
34 #define DGL_IN_STATUS_v2 1
35 #define DGL_IN_EDGESET_OFFSET_v2 2
36 #define DGL_IN_ATTR_v2 3
37 #define DGL_IN_SIZE_v2 DGL_IN_ATTR_v2
39 #define DGL_NODE_SIZEOF_v2(nattr) \
40 (sizeof(dglInt32_t) * DGL_IN_SIZE_v2 + (nattr))
41 #define DGL_NODE_WSIZE_v2(nattr) \
42 (DGL_NODE_SIZEOF_v2(nattr) / sizeof(dglInt32_t))
43 #define DGL_NODE_ALLOC_v2(nattr) (malloc(DGL_NODE_SIZEOF_v2(nattr)))
45 #define DGL_NODE_ID_v2(p) ((p)[DGL_IN_NODEID_v2])
46 #define DGL_NODE_STATUS_v2(p) ((p)[DGL_IN_STATUS_v2])
47 #define DGL_NODE_EDGESET_OFFSET_v2(p) ((p)[DGL_IN_EDGESET_OFFSET_v2])
48 #define DGL_NODE_ATTR_PTR_v2(p) ((p) + DGL_IN_ATTR_v2)
53 #define DGL_ILA_TOCNT_v2 0
54 #define DGL_ILA_SIZE_v2 1
55 #define DGL_ILA_TOARR_v2 DGL_ILA_SIZE_v2
57 #define DGL_EDGESET_SIZEOF_v2(C, lattr) (sizeof(dglInt32_t) * ((C) + 1))
58 #define DGL_EDGESET_WSIZE_v2(C, lattr) \
59 (DGL_EDGESET_SIZEOF_v2(C, lattr) / sizeof(dglInt32_t))
60 #define DGL_EDGESET_ALLOC_v2(C, lattr) (malloc(DGL_EDGESET_SIZEOF_v2(C, lattr)))
61 #define DGL_EDGESET_REALLOC_v2(P, C, lattr) \
62 (realloc(P, DGL_EDGESET_SIZEOF_v2(C, lattr)))
64 #define DGL_EDGESET_EDGECOUNT_v2(p) ((p)[DGL_ILA_TOCNT_v2])
65 #define DGL_EDGESET_EDGEARRAY_PTR_v2(p) ((p) + DGL_ILA_TOARR_v2)
66 #define DGL_EDGESET_EDGE_PTR_v2(pgrp, p, i) \
67 DGL_EDGEBUFFER_SHIFT_v2(pgrp, *((p) + DGL_ILA_TOARR_v2 + (i)))
72 #define DGL_IL_HEAD_OFFSET_v2 0
73 #define DGL_IL_TAIL_OFFSET_v2 1
74 #define DGL_IL_STATUS_v2 2
75 #define DGL_IL_COST_v2 3
76 #define DGL_IL_ID_v2 4
77 #define DGL_IL_ATTR_v2 5
78 #define DGL_IL_SIZE_v2 DGL_IL_ATTR_v2
80 #define DGL_EDGE_SIZEOF_v2(lattr) \
81 (sizeof(dglInt32_t) * DGL_IL_SIZE_v2 + (lattr))
82 #define DGL_EDGE_WSIZE_v2(lattr) \
83 (DGL_EDGE_SIZEOF_v2(lattr) / sizeof(dglInt32_t))
84 #define DGL_EDGE_ALLOC_v2(lattr) (malloc(DGL_EDGE_SIZEOF_v2(lattr)))
86 #define DGL_EDGE_HEADNODE_OFFSET_v2(p) ((p)[DGL_IL_HEAD_OFFSET_v2])
87 #define DGL_EDGE_TAILNODE_OFFSET_v2(p) ((p)[DGL_IL_TAIL_OFFSET_v2])
88 #define DGL_EDGE_STATUS_v2(p) ((p)[DGL_IL_STATUS_v2])
89 #define DGL_EDGE_COST_v2(p) ((p)[DGL_IL_COST_v2])
90 #define DGL_EDGE_ID_v2(p) ((p)[DGL_IL_ID_v2])
91 #define DGL_EDGE_ATTR_PTR_v2(p) ((p) + DGL_IL_ATTR_v2)
92 #define DGL_EDGE_HEADNODE_ID_v2(pgrp, pl) \
94 ? DGL_NODE_ID_v2(pgrp->pNodeBuffer + DGL_EDGE_HEADNODE_OFFSET_v2(pl)) \
95 : DGL_EDGE_HEADNODE_OFFSET_v2(pl))
96 #define DGL_EDGE_TAILNODE_ID_v2(pgrp, pl) \
98 ? DGL_NODE_ID_v2(pgrp->pNodeBuffer + DGL_EDGE_TAILNODE_OFFSET_v2(pl)) \
99 : DGL_EDGE_TAILNODE_OFFSET_v2(pl))
104 #define DGL_FOREACH_NODE_v2(pgrp, pn) \
105 for ((pn) = (dglInt32_t *)(pgrp)->pNodeBuffer; \
106 (pgrp)->pNodeBuffer && \
107 (pn) < (dglInt32_t *)((pgrp)->pNodeBuffer + (pgrp)->iNodeBuffer); \
108 (pn) += DGL_NODE_WSIZE_v2((pgrp)->NodeAttrSize))
112 #define DGL_FOREACH_EDGE_v2(pgrp, pla, pl, il) \
113 for ((il) = 0, (pl) = DGL_EDGESET_EDGE_PTR_v2(pgrp, pla, il); \
114 (il) < DGL_EDGESET_EDGECOUNT_v2(pla); \
115 (il)++, (pl) = DGL_EDGESET_EDGE_PTR_v2(pgrp, pla, il))
119 #define DGL_NODEBUFFER_SHIFT_v2(pgrp, o) \
120 ((dglInt32_t *)((pgrp)->pNodeBuffer + (o)))
121 #define DGL_NODEBUFFER_OFFSET_v2(pgrp, p) \
122 ((dglInt32_t)((dglByte_t *)p - (dglByte_t *)(pgrp)->pNodeBuffer))
127 #define DGL_EDGEBUFFER_SHIFT_v2(pgrp, o) \
128 ((dglInt32_t *)((pgrp)->pEdgeBuffer + (o)))
129 #define DGL_EDGEBUFFER_OFFSET_v2(pgrp, pl) \
130 ((dglInt32_t)((dglByte_t *)pl - (dglByte_t *)(pgrp)->pEdgeBuffer))
134 void *pvTailAttr,
void *pvEdgeAttr,
dglInt32_t nFlags);
int(* dglSPClip_fn)(dglGraph_s *, dglSPClipInput_s *, dglSPClipOutput_s *, void *)
int(* dglSpanClip_fn)(dglGraph_s *, dglGraph_s *, dglSpanClipInput_s *, dglSpanClipOutput_s *, void *)
int dgl_dijkstra_V2(dglGraph_s *pgraph, dglSPReport_s **ppReport, dglInt32_t *pDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
dglInt32_t * dgl_node_t_first_V2(dglNodeTraverser_s *pT)
dglInt32_t * dgl_edge_t_next_V2(dglEdgeTraverser_s *pT)
int dgl_span_minimum_spanning_V2_TREE(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
int dgl_edgeset_t_initialize_V2(dglGraph_s *pGraph, dglEdgesetTraverser_s *pTraverser, dglInt32_t *pnEdgeset)
int dgl_write_V2(dglGraph_s *pgraph, int fd)
int dgl_dijkstra_V2_FLAT(dglGraph_s *pgraph, dglSPReport_s **ppReport, dglInt32_t *pDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int dgl_release_V2(dglGraph_s *pgraph)
int dgl_add_edge_V2(dglGraph_s *pgraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge, void *pvHeadAttr, void *pvTailAttr, void *pvEdgeAttr, dglInt32_t nFlags)
int dgl_flatten_V2(dglGraph_s *pgraph)
int dgl_node_t_initialize_V2(dglGraph_s *pGraph, dglNodeTraverser_s *pT)
int dgl_edge_t_initialize_V2(dglGraph_s *pGraph, dglEdgeTraverser_s *pTraverser, dglEdgePrioritizer_s *pEP)
int dgl_del_node_inedge_V2(dglGraph_s *pgraph, dglInt32_t nNode, dglInt32_t nEdge)
int dgl_dijkstra_V2_TREE(dglGraph_s *pgraph, dglSPReport_s **ppReport, dglInt32_t *pDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int dgl_del_node_outedge_V2(dglGraph_s *pgraph, dglInt32_t nNode, dglInt32_t nEdge)
int dgl_depthfirst_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dgl_span_minimum_spanning_V2_FLAT(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
void dgl_sp_cache_release_V2(dglGraph_s *pgraph, dglSPCache_s *pCache)
int dgl_initialize_V2(dglGraph_s *pgraph)
int dgl_unflatten_V2(dglGraph_s *pgraph)
dglInt32_t * dgl_getnode_inedgeset_V2(dglGraph_s *pgraph, dglInt32_t *pnode)
void dgl_edgeset_t_release_V2(dglEdgesetTraverser_s *pTraverser)
int dgl_read_V2(dglGraph_s *pgraph, int fd, int version)
dglInt32_t * dgl_edgeset_t_first_V2(dglEdgesetTraverser_s *pTraverser)
dglInt32_t * dgl_edge_t_first_V2(dglEdgeTraverser_s *pT)
int dgl_del_edge_V2(dglGraph_s *pgraph, dglInt32_t nId)
dglInt32_t * dgl_edgeset_t_next_V2(dglEdgesetTraverser_s *pTraverser)
int dgl_span_depthfirst_spanning_V2_FLAT(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dgl_del_node_V2(dglGraph_s *pgraph, dglInt32_t nId)
int dgl_sp_cache_initialize_V2(dglGraph_s *pgraph, dglSPCache_s *pCache, dglInt32_t nStart)
void dgl_node_t_release_V2(dglNodeTraverser_s *pT)
dglInt32_t * dgl_get_node_V2(dglGraph_s *pgraph, dglInt32_t nId)
int dgl_add_node_V2(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
dglInt32_t * dgl_get_edge_V2(dglGraph_s *pgraph, dglInt32_t nId)
dglInt32_t * dgl_node_t_find_V2(dglNodeTraverser_s *pT, dglInt32_t nId)
int dgl_span_depthfirst_spanning_V2_TREE(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dgl_minimum_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
dglInt32_t * dgl_getnode_outedgeset_V2(dglGraph_s *pgraph, dglInt32_t *pnode)
void dgl_edge_t_release_V2(dglEdgeTraverser_s *pTraverser)
dglInt32_t * dgl_node_t_next_V2(dglNodeTraverser_s *pT)