GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-9b28d7b83c
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 UNUSED)
 
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 UNUSED, 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 UNUSED)
 
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 UNUSED)
 
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 1491 of file vector/dglib/graph.c.

◆ __CIO_END

#define __CIO_END   7

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

◆ __CIO_R_EDGEBUFFER

#define __CIO_R_EDGEBUFFER   6

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

◆ __CIO_R_HEADER

#define __CIO_R_HEADER   4

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

◆ __CIO_R_NODEBUFFER

#define __CIO_R_NODEBUFFER   5

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

◆ __CIO_W_EDGEBUFFER

#define __CIO_W_EDGEBUFFER   3

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

◆ __CIO_W_HEADER

#define __CIO_W_HEADER   1

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

◆ __CIO_W_NODEBUFFER

#define __CIO_W_NODEBUFFER   2

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

◆ 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  UNUSED)

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

◆ dglEdgesetGet_EdgeCount()

◆ dglErrno()

int dglErrno ( dglGraph_s pgraph)

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

References _dglGraph::iErrno.

◆ dglFlatten()

int dglFlatten ( dglGraph_s pGraph)

◆ dglFreeSPReport()

void dglFreeSPReport ( dglGraph_s *pgraph  UNUSED,
dglSPReport_s pSPReport 
)

◆ dglGet_AloneNodeCount()

int dglGet_AloneNodeCount ( dglGraph_s pgraph)

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

References _dglGraph::cAlone.

◆ dglGet_Cost()

dglInt64_t dglGet_Cost ( dglGraph_s pgraph)

Definition at line 1253 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 1283 of file vector/dglib/graph.c.

References _dglGraph::edgePrioritizer.

◆ dglGet_EdgeSize()

◆ dglGet_Endianess()

int dglGet_Endianess ( dglGraph_s pgraph)

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

References _dglGraph::Endian.

◆ dglGet_Family()

dglInt32_t dglGet_Family ( dglGraph_s pgraph)

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

References _dglGraph::nFamily.

◆ dglGet_HeadNodeCount()

int dglGet_HeadNodeCount ( dglGraph_s pgraph)

Definition at line 1188 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 1288 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 1273 of file vector/dglib/graph.c.

References _dglGraph::nOptions.

◆ dglGet_State()

int dglGet_State ( dglGraph_s pgraph)

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

References _dglGraph::Flags.

◆ dglGet_TailNodeCount()

int dglGet_TailNodeCount ( dglGraph_s pgraph)

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

References _dglGraph::cTail.

◆ dglGet_Version()

int dglGet_Version ( dglGraph_s pgraph)

Definition at line 1159 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  UNUSED)

Definition at line 1510 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 351 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 1627 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  UNUSED)

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

◆ dglSet_Cost()

void dglSet_Cost ( dglGraph_s pgraph,
dglInt64_t  nnCost 
)

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

References _dglGraph::nnCost.

◆ dglSet_Family()

void dglSet_Family ( dglGraph_s pgraph,
dglInt32_t  nFamily 
)

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

References _dglGraph::nFamily.

◆ dglSet_Opaque()

void dglSet_Opaque ( dglGraph_s pgraph,
dglInt32_t pOpaque 
)

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

References _dglGraph::aOpaqueSet.

◆ dglSet_Options()

void dglSet_Options ( dglGraph_s pgraph,
dglInt32_t  nOptions 
)

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

References _dglGraph::nOptions.

◆ dglSet_Version()

void dglSet_Version ( dglGraph_s pgraph,
int  nVersion 
)

Definition at line 1163 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()