25 #include <sys/types.h> 47 pgraph->clkAddEdge = 0;
49 pgraph->clkNodeTree = 0;
50 pgraph->cNodeTree = 0;
643 pGraph->clkAddEdge += clock() - clk;
654 void *pvTailAttr,
void *pvEdgeAttr,
dglInt32_t nFlags)
668 pvTailAttr, pvEdgeAttr, nFlags);
675 pvTailAttr, pvEdgeAttr, nFlags);
684 pGraph->clkAddEdge += clock() - clk;
761 if (read(fd, &bVersion, 1) != 1) {
799 fnClip, pvClipArg, pCache);
806 fnClip, pvClipArg, pCache);
831 fnClip, pvClipArg, pCache);
838 fnClip, pvClipArg, pCache);
864 if (pgraphInput->
Version == 2) {
866 return -pgraphInput->
iErrno;
883 return -pgraphInput->
iErrno;
886 switch (pgraphInput->
Version) {
890 pvVisited, fnClip, pvClipArg);
897 pvVisited, fnClip, pvClipArg);
902 nRet = -pgraphInput->
iErrno;
917 int cgraphComponents,
933 return -pgraphInput->
iErrno;
953 switch (pgraphInput->
Version) {
972 if (pvertex ==
NULL) {
977 for (i = 0; i < cgraphComponents && pvertex; i++) {
987 switch (pgraphInput->
Version) {
1009 nret = -pgraphInput->
iErrno;
1023 switch (pgraphInput->
Version) {
1082 switch (pgraphInput->
Version) {
1098 nRet = -pgraphInput->
iErrno;
1112 if (pSPReport->
pArc) {
1113 for (iArc = 0; iArc < pSPReport->
cArc; iArc++) {
1163 switch (pgraph->
iErrno) {
1165 return "Bad Version";
1167 return "Bad Node Type";
1169 return "Memory Exhausted";
1171 return "Heap Error";
1173 return "Undefined Method";
1179 return "Not Supported";
1181 return "Unknown Byte Order";
1183 return "Node Not Found";
1185 return "Head Node Not Found";
1187 return "Tail Node Not Found";
1191 return "Operation Not Supported On Flat-State Graph";
1193 return "Operation Not Supported On Tree-State Graph";
1195 return "Tree Search Error";
1197 return "Unexpected Null Pointer";
1199 return "Version Not Supported";
1201 return "Edge Not Found";
1203 return "Node Already Exist";
1205 return "Node Is A Component";
1207 return "Edge Already Exist";
1209 return "Bad Argument";
1212 return "unknown graph error code";
1244 return pgraph->
cNode;
1249 return pgraph->
cHead;
1254 return pgraph->
cTail;
1264 return pgraph->
cEdge;
1269 return pgraph->
Flags;
1555 #define __CIO_BEGIN 0 1556 #define __CIO_W_HEADER 1 1557 #define __CIO_W_NODEBUFFER 2 1558 #define __CIO_W_EDGEBUFFER 3 1559 #define __CIO_R_HEADER 4 1560 #define __CIO_R_NODEBUFFER 5 1561 #define __CIO_R_EDGEBUFFER 6 1603 memcpy(pb, &pIO->
pG->
cNode, 4);
1605 memcpy(pb, &pIO->
pG->
cHead, 4);
1607 memcpy(pb, &pIO->
pG->
cTail, 4);
1611 memcpy(pb, &pIO->
pG->
cEdge, 4);
1618 cb = pfn(pIO->
pG, pIO->
pb, pIO->
cb, pv);
1621 if ((pIO->
cb - pIO->
ib) == 0) {
1633 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1636 if ((pIO->
cb - pIO->
ib) == 0) {
1659 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1662 if ((pIO->
cb - pIO->
ib) == 0) {
1676 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1679 if ((pIO->
cb - pIO->
ib) == 0) {
1685 pfn(pIO->
pG,
NULL, 0, pv);
1702 c =
MIN(cbChunk, 118);
1703 memcpy(pIO->
pb, pbChunk, c);
1705 if ((pIO->
cb - pIO->
ib) == 0)
1706 goto init_nodebuffer;
1711 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1712 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1715 if ((pIO->
cb - pIO->
ib) == 0) {
1733 memcpy(&pIO->
pG->
cNode, pb, 4);
1735 memcpy(&pIO->
pG->
cHead, pb, 4);
1737 memcpy(&pIO->
pG->
cTail, pb, 4);
1741 memcpy(&pIO->
pG->
cEdge, pb, 4);
1749 #ifdef DGL_ENDIAN_BIG 1770 for (i = 0; i < 16; i++) {
1774 #ifdef DGL_ENDIAN_BIG 1792 goto init_edgebuffer;
1797 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1798 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1801 if ((pIO->
cb - pIO->
ib) == 0) {
1818 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1819 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1821 if ((pIO->
cb - pIO->
ib) == 0) {
1839 in = 0; in < cn; in++) {
1849 in = 0; in < cn; in++) {
#define DGL_ERR_BadArgument
dglInt32_t * dgl_node_t_next_V2(dglNodeTraverser_s *pT)
#define DGL_ERR_VersionNotSupported
int dglMinimumSpanning(dglGraph_s *pgraphInput, dglGraph_s *pgraphOutput, dglInt32_t nVertexNode, dglSpanClip_fn fnClip, void *pvClipArg)
dglEdgePrioritizer_s * dglGet_EdgePrioritizer(dglGraph_s *pGraph)
void dgl_node_t_release_V2(dglNodeTraverser_s *pT)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
dglEdgePrioritizer_s edgePrioritizer
dglInt32_t * dgl_get_node_V2(dglGraph_s *pgraph, dglInt32_t nId)
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)
#define DGL_ERR_UnknownByteOrder
dglNodePrioritizer_s * dglGet_NodePrioritizer(dglGraph_s *pGraph)
int dgl_release_V2(dglGraph_s *pgraph)
void dglTreeNodeCancel(void *pvNode, void *pvParam)
void dgl_sp_cache_release_V1(dglGraph_s *pgraph, dglSPCache_s *pCache)
int dglNodeGet_Valence(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dgl_read_V2(dglGraph_s *pgraph, int fd, int version)
void dglNodeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode, dglInt32_t *pnAttr)
dglInt32_t * dgl_getnode_outedgeset_V2(dglGraph_s *pgraph, dglInt32_t *pnode)
#define DGL_NODEBUFFER_SHIFT_v2(pgrp, o)
void dgl_edge_t_release_V2(dglEdgeTraverser_s *pTraverser)
#define DGL_EDGE_ID_v1(p)
#define DGL_ERR_TreeSearchError
#define DGL_EDGE_COST_v2(p)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
#define DGL_ERR_NodeAlreadyExist
#define DGL_EDGE_SIZEOF_v2(lattr)
int dgl_initialize_V1(dglGraph_s *pgraph)
#define __CIO_R_NODEBUFFER
#define DGL_ERR_EdgeAlreadyExist
dglNodePrioritizer_s nodePrioritizer
dglInt32_t * dgl_edge_t_next_V2(dglEdgeTraverser_s *pT)
void dglNode_T_Release(dglNodeTraverser_s *pT)
#define DGL_EDGESET_EDGECOUNT_v1(p)
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int dgl_del_node_V2(dglGraph_s *pgraph, dglInt32_t nId)
int dgl_del_node_V1(dglGraph_s *pgraph, dglInt32_t nId)
void dgl_sp_cache_release_V2(dglGraph_s *pgraph, dglSPCache_s *pCache)
int dgl_release_V1(dglGraph_s *pgraph)
int dgl_node_t_initialize_V1(dglGraph_s *pGraph, dglNodeTraverser_s *pT)
dglInt32_t * dgl_node_t_find_V2(dglNodeTraverser_s *pT, dglInt32_t nId)
int dglEdgeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnAttr, dglInt32_t *pnEdge)
int dgl_sp_cache_initialize_V2(dglGraph_s *pgraph, dglSPCache_s *pCache, dglInt32_t nStart)
dglInt32_t * dgl_get_edge_V1(dglGraph_s *pgraph, dglInt32_t nId)
dglInt32_t * dglEdgeGet_Head(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglEdge_T_Next(dglEdgeTraverser_s *pT)
void dglSet_Version(dglGraph_s *pgraph, int nVersion)
int dglDelNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
void dgl_swapInt64Bytes(dglInt64_t *pn)
#define DGL_NODE_ID_v2(p)
int dglGet_NodeCount(dglGraph_s *pgraph)
int dgl_node_t_initialize_V2(dglGraph_s *pGraph, dglNodeTraverser_s *pT)
int(* dglSpanClip_fn)(dglGraph_s *, dglGraph_s *, dglSpanClipInput_s *, dglSpanClipOutput_s *, void *)
dglInt32_t * dglEdgeGet_Tail(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglGet_Opaque(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)
dglInt32_t dglNodeGet_Status(dglGraph_s *pGraph, dglInt32_t *pnNode)
#define DGL_EDGE_ID_v2(p)
int dglGet_EdgeAttrSize(dglGraph_s *pgraph)
#define DGL_ERR_HeadNodeNotFound
dglInt32_t * dgl_edge_t_first_V1(dglEdgeTraverser_s *pT)
#define DGL_NODE_SIZEOF_v1(nattr)
#define DGL_NODE_SIZEOF_v2(nattr)
int dgl_edgeset_t_initialize_V1(dglGraph_s *pGraph, dglEdgesetTraverser_s *pTraverser, dglInt32_t *pnEdgeset)
int dgl_add_edge_V1(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_dijkstra_V1(dglGraph_s *pgraph, dglSPReport_s **ppReport, dglInt32_t *pDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int dglGet_Version(dglGraph_s *pgraph)
int dglInitialize(dglGraph_s *pGraph, dglByte_t Version, dglInt32_t NodeAttrSize, dglInt32_t EdgeAttrSize, dglInt32_t *pOpaqueSet)
int dgl_sp_cache_initialize_V1(dglGraph_s *pgraph, dglSPCache_s *pCache, dglInt32_t nStart)
dglInt32_t * dglEdge_T_First(dglEdgeTraverser_s *pT)
dglInt32_t * dgl_edgeset_t_next_V1(dglEdgesetTraverser_s *pTraverser)
#define DGL_EDGE_ATTR_PTR_v1(p)
int dglTreeNodeCompare(const void *pvNodeA, const void *pvNodeB, void *pvParam)
dglInt32_t * dgl_get_edge_V2(dglGraph_s *pgraph, dglInt32_t nId)
int dglGet_HeadNodeCount(dglGraph_s *pgraph)
#define DGL_ERR_BadVersion
int dglGet_Endianess(dglGraph_s *pgraph)
int dgl_write_V2(dglGraph_s *pgraph, int fd)
void dgl_node_t_release_V1(dglNodeTraverser_s *pT)
void dglSet_Opaque(dglGraph_s *pgraph, dglInt32_t *pOpaque)
dglInt32_t * dgl_getnode_inedgeset_V2(dglGraph_s *pgraph, dglInt32_t *pnode)
#define DGL_EDGE_TAILNODE_OFFSET_v2(p)
int dgl_minimum_spanning_V1(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
dglInt32_t aOpaqueSet[16]
#define DGL_NODE_ATTR_PTR_v1(p)
dglInt32_t * dglNode_T_First(dglNodeTraverser_s *pT)
char * dglStrerror(dglGraph_s *pgraph)
#define DGL_EDGE_TAILNODE_OFFSET_v1(p)
int dglErrno(dglGraph_s *pgraph)
int dglGet_EdgeSize(dglGraph_s *pgraph)
int dgl_depthfirst_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dglWrite(dglGraph_s *pGraph, int fd)
int dgl_del_edge_V2(dglGraph_s *pgraph, dglInt32_t nId)
int dglInitializeSPCache(dglGraph_s *pGraph, dglSPCache_s *pCache)
#define DGL_ERR_UndefinedMethod
void dglReleaseSPCache(dglGraph_s *pGraph, dglSPCache_s *pCache)
#define DGL_ERR_HeapError
#define DGL_ERR_NotSupported
void dgl_edge_t_release_V1(dglEdgeTraverser_s *pTraverser)
#define DGL_NODE_STATUS_v2(p)
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
#define __CIO_W_EDGEBUFFER
int dgl_add_node_V2(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
#define DGL_NODE_ID_v1(p)
#define DGL_EDGE_HEADNODE_OFFSET_v1(p)
void dgl_swapInt32Bytes(dglInt32_t *pn)
#define DGL_ERR_MemoryExhausted
int dgl_edge_t_initialize_V1(dglGraph_s *pGraph, dglEdgeTraverser_s *pTraverser, dglEdgePrioritizer_s *pEP)
dglInt32_t * dgl_get_node_V1(dglGraph_s *pgraph, dglInt32_t nId)
#define DGL_ERR_BadOnFlatGraph
int dgl_flatten_V2(dglGraph_s *pgraph)
int dglGet_NodeSize(dglGraph_s *pgraph)
int dgl_minimum_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
void * dglTreeGetAllocator()
#define DGL_EDGE_COST_v1(p)
int dgl_unflatten_V2(dglGraph_s *pgraph)
#define DGL_ERR_TailNodeNotFound
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT)
int dgl_initialize_V2(dglGraph_s *pgraph)
#define DGL_ENDIAN_LITTLE
void dglIOContextRelease(dglIOContext_s *pIO)
int dgl_del_edge_V1(dglGraph_s *pgraph, dglInt32_t nId)
#define __CIO_W_NODEBUFFER
int dglShortestDistance(dglGraph_s *pGraph, dglInt32_t *pnDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
#define DGL_NODE_STATUS_v1(p)
dglInt32_t * dgl_node_t_first_V1(dglNodeTraverser_s *pT)
int dglWriteChunk(dglIOContext_s *pIO, dglWriteChunk_fn pfn, void *pv)
int dglRead(dglGraph_s *pGraph, int fd)
dglInt32_t * dglGetEdge(dglGraph_s *pGraph, dglInt32_t nEdgeId)
int dglDepthSpanning(dglGraph_s *pgraphInput, dglGraph_s *pgraphOutput, dglInt32_t nVertexNode, dglSpanClip_fn fnClip, void *pvClipArg)
dglInt32_t dglEdgesetGet_EdgeCount(dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
int dgl_edgeset_t_initialize_V2(dglGraph_s *pGraph, dglEdgesetTraverser_s *pTraverser, dglInt32_t *pnEdgeset)
int dgl_add_node_V1(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
int dglGet_TailNodeCount(dglGraph_s *pgraph)
#define DGL_EDGESET_EDGECOUNT_v2(p)
#define DGL_ERR_BadOnTreeGraph
int(* dglWriteChunk_fn)(dglGraph_s *, unsigned char *pbChunk, int cbChunk, void *pvArg)
dglInt32_t * dgl_edgeset_t_next_V2(dglEdgesetTraverser_s *pTraverser)
dglInt32_t * dglNode_T_Find(dglNodeTraverser_s *pT, dglInt32_t nNodeId)
#define DGL_EDGE_ATTR_PTR_v2(p)
int dgl_unflatten_V1(dglGraph_s *pgraph)
int(* dglSPClip_fn)(dglGraph_s *, dglSPClipInput_s *, dglSPClipOutput_s *, void *)
dglInt32_t * dgl_node_t_find_V1(dglNodeTraverser_s *pT, dglInt32_t nId)
int dglEdge_T_Initialize(dglEdgeTraverser_s *pT, dglGraph_s *pGraph, dglEdgePrioritizer_s *pEdgePrioritizer)
int dglAddEdge(dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge)
int dgl_edge_t_initialize_V2(dglGraph_s *pGraph, dglEdgeTraverser_s *pTraverser, dglEdgePrioritizer_s *pEP)
int dgl_flatten_V1(dglGraph_s *pgraph)
dglInt32_t dglGet_Options(dglGraph_s *pgraph)
dglInt32_t * dgl_edge_t_first_V2(dglEdgeTraverser_s *pT)
int dglUnflatten(dglGraph_s *pGraph)
#define DGL_NODE_ATTR_PTR_v2(p)
#define DGL_ERR_EdgeNotFound
dglInt32_t * dgl_getnode_outedgeset_V1(dglGraph_s *pgraph, dglInt32_t *pnode)
int dglAddEdgeX(dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge, void *pvHeadAttr, void *pvTailAttr, void *pvEdgeAttr, dglInt32_t nFlags)
#define __CIO_R_EDGEBUFFER
#define DGL_ERR_BadNodeType
int dgl_depthfirst_spanning_V1(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dglNodeGet_InDegree(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dglNodeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dglEdgeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int dglNodeGet_OutDegree(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglGet_EdgeCount(dglGraph_s *pgraph)
void dglEdge_T_Release(dglEdgeTraverser_s *pT)
void dglResetStats(dglGraph_s *pgraph)
#define DGL_NODEBUFFER_SHIFT_v1(pgrp, o)
dglInt32_t * dgl_edgeset_t_first_V1(dglEdgesetTraverser_s *pTraverser)
int dgl_read_V1(dglGraph_s *pgraph, int fd)
dglInt32_t * dgl_node_t_next_V1(dglNodeTraverser_s *pT)
int dglDepthComponents(dglGraph_s *pgraphInput, dglGraph_s *pgraphComponents, int cgraphComponents, dglSpanClip_fn fnClip, void *pvClipArg)
int dglDelEdge(dglGraph_s *pGraph, dglInt32_t nEdgeId)
#define DGL_ERR_NodeNotFound
void dglSet_Family(dglGraph_s *pgraph, dglInt32_t nFamily)
#define DGL_ERR_UnexpectedNullPointer
int dglReadChunk(dglIOContext_s *pIO, dglByte_t *pbChunk, int cbChunk)
dglInt32_t * dglNodeGet_InEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
#define DGL_EDGE_SIZEOF_v1(lattr)
#define DGL_ERR_NodeIsAComponent
int dglNode_T_Initialize(dglNodeTraverser_s *pT, dglGraph_s *pGraph)
int dglGet_AloneNodeCount(dglGraph_s *pgraph)
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)
void dglSet_Options(dglGraph_s *pgraph, dglInt32_t nOptions)
dglInt32_t * dgl_edge_t_next_V1(dglEdgeTraverser_s *pT)
void dglSet_Cost(dglGraph_s *pgraph, dglInt64_t nnCost)
dglInt32_t * dglNodeGet_OutEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
#define DGL_EDGE_HEADNODE_OFFSET_v2(p)
int dglEdgeset_T_Initialize(dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
int dglIOContextInitialize(dglGraph_s *pG, dglIOContext_s *pIO)
int dglGet_State(dglGraph_s *pgraph)
dglInt32_t * dglNode_T_Next(dglNodeTraverser_s *pT)
int dglFlatten(dglGraph_s *pGraph)
int dglAddNode(dglGraph_s *pGraph, dglInt32_t nNodeId, void *pvNodeAttr, dglInt32_t nFlags)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int dglRelease(dglGraph_s *pGraph)
dglInt32_t * dgl_node_t_first_V2(dglNodeTraverser_s *pT)
dglInt64_t dglGet_Cost(dglGraph_s *pgraph)
void dglFreeSPReport(dglGraph_s *pgraph, dglSPReport_s *pSPReport)
dglInt32_t * dgl_edgeset_t_first_V2(dglEdgesetTraverser_s *pTraverser)
int dglGet_NodeAttrSize(dglGraph_s *pgraph)
int dglShortestPath(dglGraph_s *pGraph, dglSPReport_s **ppReport, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
dglInt32_t dglGet_Family(dglGraph_s *pgraph)
int dgl_write_V1(dglGraph_s *pgraph, int fd)