GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
vector/dglib/graph.c File Reference
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <grass/gis.h>
#include "type.h"
#include "tree.h"
#include "graph.h"
#include "graph_v1.h"
#include "graph_v2.h"
#include "helpers.h"
Include dependency graph for vector/dglib/graph.c:

Go to the source code of this file.

Macros

#define DGL_V2   1
 
#define __CIO_BEGIN   0
 
#define __CIO_W_HEADER   1
 
#define __CIO_W_NODEBUFFER   2
 
#define __CIO_W_EDGEBUFFER   3
 
#define __CIO_R_HEADER   4
 
#define __CIO_R_NODEBUFFER   5
 
#define __CIO_R_EDGEBUFFER   6
 
#define __CIO_END   7
 

Functions

void dglResetStats (dglGraph_s *pgraph)
 
int dglInitialize (dglGraph_s *pGraph, dglByte_t Version, dglInt32_t NodeAttrSize, dglInt32_t EdgeAttrSize, dglInt32_t *pOpaqueSet)
 
int dglRelease (dglGraph_s *pGraph)
 
int dglUnflatten (dglGraph_s *pGraph)
 
int dglFlatten (dglGraph_s *pGraph)
 
dglInt32_tdglGetNode (dglGraph_s *pGraph, dglInt32_t nNodeId)
 
dglInt32_tdglNodeGet_OutEdgeset (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
dglInt32_tdglNodeGet_InEdgeset (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
dglInt32_t dglNodeGet_Id (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
dglInt32_t dglNodeGet_Status (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
dglInt32_tdglNodeGet_Attr (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
void dglNodeSet_Attr (dglGraph_s *pGraph, dglInt32_t *pnNode, dglInt32_t *pnAttr)
 
int dglNodeGet_InDegree (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
int dglNodeGet_OutDegree (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
int dglNodeGet_Valence (dglGraph_s *pGraph, dglInt32_t *pnNode)
 
dglInt32_t dglEdgesetGet_EdgeCount (dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
 
dglInt32_t dglEdgeGet_Cost (dglGraph_s *pGraph, dglInt32_t *pnEdge)
 
dglInt32_t dglEdgeGet_Id (dglGraph_s *pGraph, dglInt32_t *pnEdge)
 
dglInt32_tdglEdgeGet_Head (dglGraph_s *pGraph, dglInt32_t *pnEdge)
 
dglInt32_tdglEdgeGet_Tail (dglGraph_s *pGraph, dglInt32_t *pnEdge)
 
dglInt32_tdglEdgeGet_Attr (dglGraph_s *pGraph, dglInt32_t *pnEdge)
 
int dglEdgeSet_Attr (dglGraph_s *pGraph, dglInt32_t *pnAttr, dglInt32_t *pnEdge)
 
dglInt32_tdglGetEdge (dglGraph_s *pGraph, dglInt32_t nEdgeId)
 
int dglDelEdge (dglGraph_s *pGraph, dglInt32_t nEdgeId)
 
int dglAddEdge (dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge)
 
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)
 
int dglAddNode (dglGraph_s *pGraph, dglInt32_t nNodeId, void *pvNodeAttr, dglInt32_t nFlags)
 
int dglDelNode (dglGraph_s *pGraph, dglInt32_t nNodeId)
 
int dglWrite (dglGraph_s *pGraph, int fd)
 
int dglRead (dglGraph_s *pGraph, int fd)
 
int dglShortestPath (dglGraph_s *pGraph, dglSPReport_s **ppReport, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
 
int dglShortestDistance (dglGraph_s *pGraph, dglInt32_t *pnDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
 
int dglDepthSpanning (dglGraph_s *pgraphInput, dglGraph_s *pgraphOutput, dglInt32_t nVertexNode, dglSpanClip_fn fnClip, void *pvClipArg)
 
int dglDepthComponents (dglGraph_s *pgraphInput, dglGraph_s *pgraphComponents, int cgraphComponents, dglSpanClip_fn fnClip, void *pvClipArg)
 
int dglMinimumSpanning (dglGraph_s *pgraphInput, dglGraph_s *pgraphOutput, dglInt32_t nVertexNode, dglSpanClip_fn fnClip, void *pvClipArg)
 
void dglFreeSPReport (dglGraph_s *pgraph, dglSPReport_s *pSPReport)
 
int dglInitializeSPCache (dglGraph_s *pGraph, dglSPCache_s *pCache)
 
void dglReleaseSPCache (dglGraph_s *pGraph, dglSPCache_s *pCache)
 
int dglErrno (dglGraph_s *pgraph)
 
char * dglStrerror (dglGraph_s *pgraph)
 
int dglGet_Version (dglGraph_s *pgraph)
 
void dglSet_Version (dglGraph_s *pgraph, int nVersion)
 
int dglGet_Endianess (dglGraph_s *pgraph)
 
int dglGet_NodeAttrSize (dglGraph_s *pgraph)
 
int dglGet_EdgeAttrSize (dglGraph_s *pgraph)
 
int dglGet_NodeCount (dglGraph_s *pgraph)
 
int dglGet_HeadNodeCount (dglGraph_s *pgraph)
 
int dglGet_TailNodeCount (dglGraph_s *pgraph)
 
int dglGet_AloneNodeCount (dglGraph_s *pgraph)
 
int dglGet_EdgeCount (dglGraph_s *pgraph)
 
int dglGet_State (dglGraph_s *pgraph)
 
dglInt32_tdglGet_Opaque (dglGraph_s *pgraph)
 
void dglSet_Opaque (dglGraph_s *pgraph, dglInt32_t *pOpaque)
 
int dglGet_NodeSize (dglGraph_s *pgraph)
 
int dglGet_EdgeSize (dglGraph_s *pgraph)
 
dglInt64_t dglGet_Cost (dglGraph_s *pgraph)
 
void dglSet_Cost (dglGraph_s *pgraph, dglInt64_t nnCost)
 
dglInt32_t dglGet_Family (dglGraph_s *pgraph)
 
void dglSet_Family (dglGraph_s *pgraph, dglInt32_t nFamily)
 
dglInt32_t dglGet_Options (dglGraph_s *pgraph)
 
void dglSet_Options (dglGraph_s *pgraph, dglInt32_t nOptions)
 
dglEdgePrioritizer_sdglGet_EdgePrioritizer (dglGraph_s *pGraph)
 
dglNodePrioritizer_sdglGet_NodePrioritizer (dglGraph_s *pGraph)
 
int dglNode_T_Initialize (dglNodeTraverser_s *pT, dglGraph_s *pGraph)
 
void dglNode_T_Release (dglNodeTraverser_s *pT)
 
dglInt32_tdglNode_T_First (dglNodeTraverser_s *pT)
 
dglInt32_tdglNode_T_Next (dglNodeTraverser_s *pT)
 
dglInt32_tdglNode_T_Find (dglNodeTraverser_s *pT, dglInt32_t nNodeId)
 
int dglEdge_T_Initialize (dglEdgeTraverser_s *pT, dglGraph_s *pGraph, dglEdgePrioritizer_s *pEdgePrioritizer)
 
void dglEdge_T_Release (dglEdgeTraverser_s *pT)
 
dglInt32_tdglEdge_T_First (dglEdgeTraverser_s *pT)
 
dglInt32_tdglEdge_T_Next (dglEdgeTraverser_s *pT)
 
int dglEdgeset_T_Initialize (dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
 
void dglEdgeset_T_Release (dglEdgesetTraverser_s *pT)
 
dglInt32_tdglEdgeset_T_First (dglEdgesetTraverser_s *pT)
 
dglInt32_tdglEdgeset_T_Next (dglEdgesetTraverser_s *pT)
 
int dglIOContextInitialize (dglGraph_s *pG, dglIOContext_s *pIO)
 
void dglIOContextRelease (dglIOContext_s *pIO)
 
int dglWriteChunk (dglIOContext_s *pIO, dglWriteChunk_fn pfn, void *pv)
 
int dglReadChunk (dglIOContext_s *pIO, dglByte_t *pbChunk, int cbChunk)
 

Macro Definition Documentation

◆ __CIO_BEGIN

#define __CIO_BEGIN   0

Definition at line 1555 of file vector/dglib/graph.c.

Referenced by dglIOContextInitialize(), and dglWriteChunk().

◆ __CIO_END

#define __CIO_END   7

Definition at line 1562 of file vector/dglib/graph.c.

Referenced by dglWriteChunk().

◆ __CIO_R_EDGEBUFFER

#define __CIO_R_EDGEBUFFER   6

Definition at line 1561 of file vector/dglib/graph.c.

◆ __CIO_R_HEADER

#define __CIO_R_HEADER   4

Definition at line 1559 of file vector/dglib/graph.c.

◆ __CIO_R_NODEBUFFER

#define __CIO_R_NODEBUFFER   5

Definition at line 1560 of file vector/dglib/graph.c.

◆ __CIO_W_EDGEBUFFER

#define __CIO_W_EDGEBUFFER   3

Definition at line 1558 of file vector/dglib/graph.c.

Referenced by dglWriteChunk().

◆ __CIO_W_HEADER

#define __CIO_W_HEADER   1

Definition at line 1556 of file vector/dglib/graph.c.

Referenced by dglWriteChunk().

◆ __CIO_W_NODEBUFFER

#define __CIO_W_NODEBUFFER   2

Definition at line 1557 of file vector/dglib/graph.c.

Referenced by dglWriteChunk().

◆ DGL_V2

#define DGL_V2   1

Definition at line 31 of file vector/dglib/graph.c.

Function Documentation

◆ dglAddEdge()

int dglAddEdge ( dglGraph_s pGraph,
dglInt32_t  nHead,
dglInt32_t  nTail,
dglInt32_t  nCost,
dglInt32_t  nEdge 
)

◆ dglAddEdgeX()

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 
)

◆ dglAddNode()

int dglAddNode ( dglGraph_s pGraph,
dglInt32_t  nNodeId,
void *  pvNodeAttr,
dglInt32_t  nFlags 
)

◆ dglDelEdge()

int dglDelEdge ( dglGraph_s pGraph,
dglInt32_t  nEdgeId 
)

◆ dglDelNode()

int dglDelNode ( dglGraph_s pGraph,
dglInt32_t  nNodeId 
)

◆ dglDepthComponents()

◆ dglDepthSpanning()

◆ dglEdge_T_First()

◆ dglEdge_T_Initialize()

int dglEdge_T_Initialize ( dglEdgeTraverser_s pT,
dglGraph_s pGraph,
dglEdgePrioritizer_s pEdgePrioritizer 
)

◆ dglEdge_T_Next()

◆ dglEdge_T_Release()

◆ dglEdgeGet_Attr()

◆ dglEdgeGet_Cost()

◆ dglEdgeGet_Head()

◆ dglEdgeGet_Id()

◆ dglEdgeGet_Tail()

◆ dglEdgeSet_Attr()

◆ dglEdgeset_T_First()

◆ dglEdgeset_T_Initialize()

int dglEdgeset_T_Initialize ( dglEdgesetTraverser_s pT,
dglGraph_s pGraph,
dglInt32_t pnEdgeset 
)

◆ dglEdgeset_T_Next()

◆ dglEdgeset_T_Release()

void dglEdgeset_T_Release ( dglEdgesetTraverser_s pT)

Definition at line 1516 of file vector/dglib/graph.c.

◆ dglEdgesetGet_EdgeCount()

◆ dglErrno()

int dglErrno ( dglGraph_s pgraph)

Definition at line 1156 of file vector/dglib/graph.c.

References _dglGraph::iErrno.

◆ dglFlatten()

int dglFlatten ( dglGraph_s pGraph)

◆ dglFreeSPReport()

void dglFreeSPReport ( dglGraph_s pgraph,
dglSPReport_s pSPReport 
)

◆ dglGet_AloneNodeCount()

int dglGet_AloneNodeCount ( dglGraph_s pgraph)

Definition at line 1257 of file vector/dglib/graph.c.

References _dglGraph::cAlone.

◆ dglGet_Cost()

dglInt64_t dglGet_Cost ( dglGraph_s pgraph)

Definition at line 1312 of file vector/dglib/graph.c.

References _dglGraph::nnCost.

◆ dglGet_EdgeAttrSize()

int dglGet_EdgeAttrSize ( dglGraph_s pgraph)

◆ dglGet_EdgeCount()

int dglGet_EdgeCount ( dglGraph_s pgraph)

◆ dglGet_EdgePrioritizer()

dglEdgePrioritizer_s* dglGet_EdgePrioritizer ( dglGraph_s pGraph)

Definition at line 1342 of file vector/dglib/graph.c.

References _dglGraph::edgePrioritizer.

◆ dglGet_EdgeSize()

◆ dglGet_Endianess()

int dglGet_Endianess ( dglGraph_s pgraph)

Definition at line 1227 of file vector/dglib/graph.c.

References _dglGraph::Endian.

◆ dglGet_Family()

dglInt32_t dglGet_Family ( dglGraph_s pgraph)

Definition at line 1322 of file vector/dglib/graph.c.

References _dglGraph::nFamily.

◆ dglGet_HeadNodeCount()

int dglGet_HeadNodeCount ( dglGraph_s pgraph)

Definition at line 1247 of file vector/dglib/graph.c.

References _dglGraph::cHead.

◆ dglGet_NodeAttrSize()

◆ dglGet_NodeCount()

◆ dglGet_NodePrioritizer()

dglNodePrioritizer_s* dglGet_NodePrioritizer ( dglGraph_s pGraph)

Definition at line 1347 of file vector/dglib/graph.c.

References _dglGraph::nodePrioritizer.

◆ dglGet_NodeSize()

◆ dglGet_Opaque()

dglInt32_t* dglGet_Opaque ( dglGraph_s pgraph)

◆ dglGet_Options()

dglInt32_t dglGet_Options ( dglGraph_s pgraph)

Definition at line 1332 of file vector/dglib/graph.c.

References _dglGraph::nOptions.

◆ dglGet_State()

int dglGet_State ( dglGraph_s pgraph)

Definition at line 1267 of file vector/dglib/graph.c.

References _dglGraph::Flags.

◆ dglGet_TailNodeCount()

int dglGet_TailNodeCount ( dglGraph_s pgraph)

Definition at line 1252 of file vector/dglib/graph.c.

References _dglGraph::cTail.

◆ dglGet_Version()

int dglGet_Version ( dglGraph_s pgraph)

Definition at line 1218 of file vector/dglib/graph.c.

References _dglGraph::Version.

Referenced by dglDepthComponents(), dglDepthSpanning(), and dglMinimumSpanning().

◆ dglGetEdge()

dglInt32_t* dglGetEdge ( dglGraph_s pGraph,
dglInt32_t  nEdgeId 
)

◆ dglGetNode()

◆ dglInitialize()

◆ dglInitializeSPCache()

int dglInitializeSPCache ( dglGraph_s pGraph,
dglSPCache_s pCache 
)

◆ dglIOContextInitialize()

int dglIOContextInitialize ( dglGraph_s pG,
dglIOContext_s pIO 
)

◆ dglIOContextRelease()

void dglIOContextRelease ( dglIOContext_s pIO)

Definition at line 1574 of file vector/dglib/graph.c.

◆ dglMinimumSpanning()

◆ dglNode_T_Find()

◆ dglNode_T_First()

◆ dglNode_T_Initialize()

◆ dglNode_T_Next()

◆ dglNode_T_Release()

◆ dglNodeGet_Attr()

◆ dglNodeGet_Id()

◆ dglNodeGet_InDegree()

◆ dglNodeGet_InEdgeset()

dglInt32_t* dglNodeGet_InEdgeset ( dglGraph_s pGraph,
dglInt32_t pnNode 
)

◆ dglNodeGet_OutDegree()

◆ dglNodeGet_OutEdgeset()

dglInt32_t* dglNodeGet_OutEdgeset ( dglGraph_s pGraph,
dglInt32_t pnNode 
)

◆ dglNodeGet_Status()

◆ dglNodeGet_Valence()

int dglNodeGet_Valence ( dglGraph_s pGraph,
dglInt32_t pnNode 
)

Definition at line 364 of file vector/dglib/graph.c.

Referenced by dglNodeGet_InDegree(), and dglNodeGet_OutDegree().

◆ dglNodeSet_Attr()

void dglNodeSet_Attr ( dglGraph_s pGraph,
dglInt32_t pnNode,
dglInt32_t pnAttr 
)

◆ dglRead()

int dglRead ( dglGraph_s pGraph,
int  fd 
)

◆ dglReadChunk()

int dglReadChunk ( dglIOContext_s pIO,
dglByte_t pbChunk,
int  cbChunk 
)

Definition at line 1691 of file vector/dglib/graph.c.

◆ dglRelease()

int dglRelease ( dglGraph_s pGraph)

◆ dglReleaseSPCache()

void dglReleaseSPCache ( dglGraph_s pGraph,
dglSPCache_s pCache 
)

◆ dglResetStats()

void dglResetStats ( dglGraph_s pgraph)

Definition at line 44 of file vector/dglib/graph.c.

◆ dglSet_Cost()

void dglSet_Cost ( dglGraph_s pgraph,
dglInt64_t  nnCost 
)

Definition at line 1317 of file vector/dglib/graph.c.

References _dglGraph::nnCost.

◆ dglSet_Family()

void dglSet_Family ( dglGraph_s pgraph,
dglInt32_t  nFamily 
)

Definition at line 1327 of file vector/dglib/graph.c.

References _dglGraph::nFamily.

◆ dglSet_Opaque()

void dglSet_Opaque ( dglGraph_s pgraph,
dglInt32_t pOpaque 
)

Definition at line 1277 of file vector/dglib/graph.c.

References _dglGraph::aOpaqueSet.

◆ dglSet_Options()

void dglSet_Options ( dglGraph_s pgraph,
dglInt32_t  nOptions 
)

Definition at line 1337 of file vector/dglib/graph.c.

References _dglGraph::nOptions.

◆ dglSet_Version()

void dglSet_Version ( dglGraph_s pgraph,
int  nVersion 
)

Definition at line 1222 of file vector/dglib/graph.c.

References _dglGraph::Version.

◆ dglShortestDistance()

int dglShortestDistance ( dglGraph_s pGraph,
dglInt32_t pnDistance,
dglInt32_t  nStart,
dglInt32_t  nDestination,
dglSPClip_fn  fnClip,
void *  pvClipArg,
dglSPCache_s pCache 
)

◆ dglShortestPath()

int dglShortestPath ( dglGraph_s pGraph,
dglSPReport_s **  ppReport,
dglInt32_t  nStart,
dglInt32_t  nDestination,
dglSPClip_fn  fnClip,
void *  pvClipArg,
dglSPCache_s pCache 
)

◆ dglStrerror()

◆ dglUnflatten()

int dglUnflatten ( dglGraph_s pGraph)

◆ dglWrite()

int dglWrite ( dglGraph_s pGraph,
int  fd 
)

◆ dglWriteChunk()