25 #include <sys/types.h>
46 pgraph->clkAddEdge = 0;
48 pgraph->clkNodeTree = 0;
49 pgraph->cNodeTree = 0;
642 pGraph->clkAddEdge += clock() - clk;
653 void *pvTailAttr,
void *pvEdgeAttr,
dglInt32_t nFlags)
667 pvTailAttr, pvEdgeAttr, nFlags);
674 pvTailAttr, pvEdgeAttr, nFlags);
683 pGraph->clkAddEdge += clock() - clk;
760 if (read(fd, &bVersion, 1) != 1) {
798 fnClip, pvClipArg, pCache);
805 fnClip, pvClipArg, pCache);
830 fnClip, pvClipArg, pCache);
837 fnClip, pvClipArg, pCache);
863 if (pgraphInput->
Version == 2) {
865 return -pgraphInput->
iErrno;
882 return -pgraphInput->
iErrno;
885 switch (pgraphInput->
Version) {
889 pvVisited, fnClip, pvClipArg);
896 pvVisited, fnClip, pvClipArg);
901 nRet = -pgraphInput->
iErrno;
916 int cgraphComponents,
932 return -pgraphInput->
iErrno;
952 switch (pgraphInput->
Version) {
971 if (pvertex ==
NULL) {
976 for (i = 0; i < cgraphComponents && pvertex; i++) {
986 switch (pgraphInput->
Version) {
1008 nret = -pgraphInput->
iErrno;
1022 switch (pgraphInput->
Version) {
1081 switch (pgraphInput->
Version) {
1097 nRet = -pgraphInput->
iErrno;
1111 if (pSPReport->
pArc) {
1112 for (iArc = 0; iArc < pSPReport->
cArc; iArc++) {
1162 switch (pgraph->
iErrno) {
1164 return "Bad Version";
1166 return "Bad Node Type";
1168 return "Memory Exhausted";
1170 return "Heap Error";
1172 return "Undefined Method";
1178 return "Not Supported";
1180 return "Unknown Byte Order";
1182 return "Node Not Found";
1184 return "Head Node Not Found";
1186 return "Tail Node Not Found";
1190 return "Operation Not Supported On Flat-State Graph";
1192 return "Operation Not Supported On Tree-State Graph";
1194 return "Tree Search Error";
1196 return "Unexpected Null Pointer";
1198 return "Version Not Supported";
1200 return "Edge Not Found";
1202 return "Node Already Exist";
1204 return "Node Is A Component";
1206 return "Edge Already Exist";
1208 return "Bad Argument";
1211 return "unknown graph error code";
1243 return pgraph->
cNode;
1248 return pgraph->
cHead;
1253 return pgraph->
cTail;
1263 return pgraph->
cEdge;
1268 return pgraph->
Flags;
1554 #define __CIO_BEGIN 0
1555 #define __CIO_W_HEADER 1
1556 #define __CIO_W_NODEBUFFER 2
1557 #define __CIO_W_EDGEBUFFER 3
1558 #define __CIO_R_HEADER 4
1559 #define __CIO_R_NODEBUFFER 5
1560 #define __CIO_R_EDGEBUFFER 6
1602 memcpy(pb, &pIO->
pG->
cNode, 4);
1604 memcpy(pb, &pIO->
pG->
cHead, 4);
1606 memcpy(pb, &pIO->
pG->
cTail, 4);
1610 memcpy(pb, &pIO->
pG->
cEdge, 4);
1617 cb = pfn(pIO->
pG, pIO->
pb, pIO->
cb, pv);
1620 if ((pIO->
cb - pIO->
ib) == 0) {
1632 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1635 if ((pIO->
cb - pIO->
ib) == 0) {
1658 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1661 if ((pIO->
cb - pIO->
ib) == 0) {
1675 cb = pfn(pIO->
pG, pIO->
pb + pIO->
ib, pIO->
cb - pIO->
ib, pv);
1678 if ((pIO->
cb - pIO->
ib) == 0) {
1684 pfn(pIO->
pG,
NULL, 0, pv);
1691 #define MIN(x,y) (((x)<(y))?x:y)
1705 c =
MIN(cbChunk, 118);
1706 memcpy(pIO->
pb, pbChunk, c);
1708 if ((pIO->
cb - pIO->
ib) == 0)
1709 goto init_nodebuffer;
1714 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1715 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1718 if ((pIO->
cb - pIO->
ib) == 0) {
1736 memcpy(&pIO->
pG->
cNode, pb, 4);
1738 memcpy(&pIO->
pG->
cHead, pb, 4);
1740 memcpy(&pIO->
pG->
cTail, pb, 4);
1744 memcpy(&pIO->
pG->
cEdge, pb, 4);
1752 #ifdef DGL_ENDIAN_BIG
1773 for (i = 0; i < 16; i++) {
1777 #ifdef DGL_ENDIAN_BIG
1795 goto init_edgebuffer;
1800 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1801 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1804 if ((pIO->
cb - pIO->
ib) == 0) {
1821 c =
MIN(cbChunk, pIO->
cb - pIO->
ib);
1822 memcpy(pIO->
pb + pIO->
ib, pbChunk, c);
1824 if ((pIO->
cb - pIO->
ib) == 0) {
1842 in = 0; in < cn; in++) {
1852 in = 0; in < cn; in++) {
int dglGet_State(dglGraph_s *pgraph)
dglInt32_t * dglEdgeGet_Tail(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglNodeGet_Valence(dglGraph_s *pGraph, dglInt32_t *pnNode)
#define DGL_ERR_BadArgument
dglInt32_t * dgl_node_t_next_V2(dglNodeTraverser_s *pT)
#define DGL_ERR_VersionNotSupported
#define __CIO_W_NODEBUFFER
void dgl_node_t_release_V2(dglNodeTraverser_s *pT)
int dglShortestPath(dglGraph_s *pGraph, dglSPReport_s **ppReport, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
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
int dgl_release_V2(dglGraph_s *pgraph)
void dglTreeNodeCancel(void *pvNode, void *pvParam)
int dglAddEdge(dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge)
int dglEdgeset_T_Initialize(dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
#define __CIO_R_NODEBUFFER
void dgl_sp_cache_release_V1(dglGraph_s *pgraph, dglSPCache_s *pCache)
int dgl_read_V2(dglGraph_s *pgraph, int fd, int version)
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)
int dglGet_HeadNodeCount(dglGraph_s *pgraph)
#define DGL_ERR_NodeAlreadyExist
#define DGL_EDGE_SIZEOF_v2(lattr)
int dgl_initialize_V1(dglGraph_s *pgraph)
#define DGL_ERR_EdgeAlreadyExist
dglNodePrioritizer_s nodePrioritizer
dglInt32_t * dgl_edge_t_next_V2(dglEdgeTraverser_s *pT)
int dglGet_TailNodeCount(dglGraph_s *pgraph)
#define DGL_EDGESET_EDGECOUNT_v1(p)
dglInt64_t dglGet_Cost(dglGraph_s *pgraph)
int dglGet_EdgeAttrSize(dglGraph_s *pgraph)
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 dglAddNode(dglGraph_s *pGraph, dglInt32_t nNodeId, void *pvNodeAttr, dglInt32_t nFlags)
int dgl_sp_cache_initialize_V2(dglGraph_s *pgraph, dglSPCache_s *pCache, dglInt32_t nStart)
int dglRead(dglGraph_s *pGraph, int fd)
dglInt32_t * dgl_get_edge_V1(dglGraph_s *pgraph, dglInt32_t nId)
dglInt32_t dglNodeGet_Status(dglGraph_s *pGraph, dglInt32_t *pnNode)
void dgl_swapInt64Bytes(dglInt64_t *pn)
#define DGL_NODE_ID_v2(p)
int dglErrno(dglGraph_s *pgraph)
dglInt32_t * dglEdge_T_First(dglEdgeTraverser_s *pT)
int dgl_node_t_initialize_V2(dglGraph_s *pGraph, dglNodeTraverser_s *pT)
int dglNode_T_Initialize(dglNodeTraverser_s *pT, dglGraph_s *pGraph)
int dglGet_AloneNodeCount(dglGraph_s *pgraph)
int dglShortestDistance(dglGraph_s *pGraph, dglInt32_t *pnDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int dglGet_Version(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 dglNodeGet_OutDegree(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t dglEdgesetGet_EdgeCount(dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
int dglEdgeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnAttr, dglInt32_t *pnEdge)
void dglNode_T_Release(dglNodeTraverser_s *pT)
#define DGL_EDGE_ID_v2(p)
void dglSet_Family(dglGraph_s *pgraph, dglInt32_t nFamily)
int dglIOContextInitialize(dglGraph_s *pG, dglIOContext_s *pIO)
#define __CIO_W_EDGEBUFFER
#define DGL_ERR_HeadNodeNotFound
int dglUnflatten(dglGraph_s *pGraph)
dglInt32_t * dgl_edge_t_first_V1(dglEdgeTraverser_s *pT)
int(* dglWriteChunk_fn)(dglGraph_s *, unsigned char *pbChunk, int cbChunk, void *pvArg)
#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 dglGet_NodeAttrSize(dglGraph_s *pgraph)
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 dgl_sp_cache_initialize_V1(dglGraph_s *pgraph, dglSPCache_s *pCache, dglInt32_t nStart)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int dglInitializeSPCache(dglGraph_s *pGraph, dglSPCache_s *pCache)
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 dglRelease(dglGraph_s *pGraph)
#define DGL_ERR_BadVersion
int dgl_write_V2(dglGraph_s *pgraph, int fd)
void dgl_node_t_release_V1(dglNodeTraverser_s *pT)
dglInt32_t dglGet_Options(dglGraph_s *pgraph)
void dglEdge_T_Release(dglEdgeTraverser_s *pT)
int dglNodeGet_InDegree(dglGraph_s *pGraph, dglInt32_t *pnNode)
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT)
dglInt32_t * dgl_getnode_inedgeset_V2(dglGraph_s *pgraph, dglInt32_t *pnode)
#define DGL_EDGE_TAILNODE_OFFSET_v2(p)
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
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)
#define DGL_EDGE_TAILNODE_OFFSET_v1(p)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
dglInt32_t * dglEdge_T_Next(dglEdgeTraverser_s *pT)
int dgl_depthfirst_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
int dglWriteChunk(dglIOContext_s *pIO, dglWriteChunk_fn pfn, void *pv)
int dgl_del_edge_V2(dglGraph_s *pgraph, dglInt32_t nId)
#define DGL_ERR_UndefinedMethod
#define DGL_ERR_HeapError
int dglDelEdge(dglGraph_s *pGraph, dglInt32_t nEdgeId)
#define DGL_ERR_NotSupported
void dgl_edge_t_release_V1(dglEdgeTraverser_s *pTraverser)
int dglWrite(dglGraph_s *pGraph, int fd)
#define DGL_NODE_STATUS_v2(p)
int dglDepthComponents(dglGraph_s *pgraphInput, dglGraph_s *pgraphComponents, int cgraphComponents, dglSpanClip_fn fnClip, void *pvClipArg)
void dglNodeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode, dglInt32_t *pnAttr)
int dgl_add_node_V2(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
dglInt32_t dglGet_Family(dglGraph_s *pgraph)
int dglEdge_T_Initialize(dglEdgeTraverser_s *pT, dglGraph_s *pGraph, dglEdgePrioritizer_s *pEdgePrioritizer)
#define DGL_NODE_ID_v1(p)
#define DGL_EDGE_HEADNODE_OFFSET_v1(p)
void dgl_swapInt32Bytes(dglInt32_t *pn)
#define DGL_ERR_MemoryExhausted
int dglGet_Endianess(dglGraph_s *pgraph)
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
void dglReleaseSPCache(dglGraph_s *pGraph, dglSPCache_s *pCache)
int dglGet_NodeSize(dglGraph_s *pgraph)
int dgl_flatten_V2(dglGraph_s *pgraph)
int dgl_minimum_spanning_V2(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, dglSpanClip_fn fnClip, void *pvClipArg)
void * dglTreeGetAllocator()
dglInt32_t * dglNode_T_First(dglNodeTraverser_s *pT)
#define DGL_EDGE_COST_v1(p)
int dgl_unflatten_V2(dglGraph_s *pgraph)
dglInt32_t * dglEdgeGet_Head(dglGraph_s *pGraph, dglInt32_t *pnEdge)
#define DGL_ERR_TailNodeNotFound
int dgl_initialize_V2(dglGraph_s *pgraph)
#define DGL_ENDIAN_LITTLE
int dgl_del_edge_V1(dglGraph_s *pgraph, dglInt32_t nId)
int dglGet_EdgeCount(dglGraph_s *pgraph)
#define DGL_NODE_STATUS_v1(p)
dglInt32_t * dgl_node_t_first_V1(dglNodeTraverser_s *pT)
dglInt32_t * dglNode_T_Find(dglNodeTraverser_s *pT, dglInt32_t nNodeId)
int dgl_edgeset_t_initialize_V2(dglGraph_s *pGraph, dglEdgesetTraverser_s *pTraverser, dglInt32_t *pnEdgeset)
void dglSet_Options(dglGraph_s *pgraph, dglInt32_t nOptions)
int dgl_add_node_V1(dglGraph_s *pgraph, dglInt32_t nId, void *pvNodeAttr, dglInt32_t nFlags)
dglInt32_t * dglNodeGet_OutEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dglEdgeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnEdge)
#define DGL_EDGESET_EDGECOUNT_v2(p)
#define DGL_ERR_BadOnTreeGraph
int dglDelNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
dglInt32_t * dglNodeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dgl_edgeset_t_next_V2(dglEdgesetTraverser_s *pTraverser)
#define DGL_EDGE_ATTR_PTR_v2(p)
dglNodePrioritizer_s * dglGet_NodePrioritizer(dglGraph_s *pGraph)
int dgl_unflatten_V1(dglGraph_s *pgraph)
dglInt32_t * dgl_node_t_find_V1(dglNodeTraverser_s *pT, dglInt32_t nId)
int dgl_edge_t_initialize_V2(dglGraph_s *pGraph, dglEdgeTraverser_s *pTraverser, dglEdgePrioritizer_s *pEP)
int dgl_flatten_V1(dglGraph_s *pgraph)
dglInt32_t * dgl_edge_t_first_V2(dglEdgeTraverser_s *pT)
#define DGL_NODE_ATTR_PTR_v2(p)
#define DGL_ERR_EdgeNotFound
dglInt32_t * dglGet_Opaque(dglGraph_s *pgraph)
dglEdgePrioritizer_s * dglGet_EdgePrioritizer(dglGraph_s *pGraph)
int dglInitialize(dglGraph_s *pGraph, dglByte_t Version, dglInt32_t NodeAttrSize, dglInt32_t EdgeAttrSize, dglInt32_t *pOpaqueSet)
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
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)
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)
int dglGet_EdgeSize(dglGraph_s *pgraph)
dglInt32_t * dgl_getnode_outedgeset_V1(dglGraph_s *pgraph, dglInt32_t *pnode)
void dglIOContextRelease(dglIOContext_s *pIO)
#define DGL_ERR_BadNodeType
void dglSet_Cost(dglGraph_s *pgraph, dglInt64_t nnCost)
int dgl_depthfirst_spanning_V1(dglGraph_s *pgraphIn, dglGraph_s *pgraphOut, dglInt32_t nVertex, void *pvVisited, dglSpanClip_fn fnClip, void *pvClipArg)
#define __CIO_R_EDGEBUFFER
#define DGL_NODEBUFFER_SHIFT_v1(pgrp, o)
dglInt32_t * dgl_edgeset_t_first_V1(dglEdgesetTraverser_s *pTraverser)
char * dglStrerror(dglGraph_s *pgraph)
int dgl_read_V1(dglGraph_s *pgraph, int fd)
dglInt32_t * dgl_node_t_next_V1(dglNodeTraverser_s *pT)
#define DGL_ERR_NodeNotFound
void dglSet_Version(dglGraph_s *pgraph, int nVersion)
int(* dglSPClip_fn)(dglGraph_s *, dglSPClipInput_s *, dglSPClipOutput_s *, void *)
int dglMinimumSpanning(dglGraph_s *pgraphInput, dglGraph_s *pgraphOutput, dglInt32_t nVertexNode, dglSpanClip_fn fnClip, void *pvClipArg)
int dglGet_NodeCount(dglGraph_s *pgraph)
void dglFreeSPReport(dglGraph_s *pgraph, dglSPReport_s *pSPReport)
void dglSet_Opaque(dglGraph_s *pgraph, dglInt32_t *pOpaque)
#define DGL_ERR_UnexpectedNullPointer
void dglResetStats(dglGraph_s *pgraph)
#define DGL_EDGE_SIZEOF_v1(lattr)
#define DGL_ERR_NodeIsAComponent
dglInt32_t * dglNode_T_Next(dglNodeTraverser_s *pT)
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)
dglInt32_t * dgl_edge_t_next_V1(dglEdgeTraverser_s *pT)
int dglReadChunk(dglIOContext_s *pIO, dglByte_t *pbChunk, int cbChunk)
#define DGL_EDGE_HEADNODE_OFFSET_v2(p)
int(* dglSpanClip_fn)(dglGraph_s *, dglGraph_s *, dglSpanClipInput_s *, dglSpanClipOutput_s *, void *)
dglInt32_t * dglNodeGet_InEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dgl_node_t_first_V2(dglNodeTraverser_s *pT)
dglInt32_t * dgl_edgeset_t_first_V2(dglEdgesetTraverser_s *pTraverser)
int dglFlatten(dglGraph_s *pGraph)
int dgl_write_V1(dglGraph_s *pgraph, int fd)