18 #include <grass/gis.h>
19 #include <grass/Vect.h>
20 #include <grass/glocale.h>
21 #include <grass/dgl/graph.h>
33 struct ilist *articulation_list)
53 tin = (
int *)G_calloc(nnodes + 1,
sizeof(
int));
54 min_tin = (
int *)G_calloc(nnodes + 1,
sizeof(
int));
58 mark = (
int *)G_calloc(nnodes + 1,
sizeof(
int));
59 if (!tin || !min_tin || !parent || !stack || !current || !mark) {
64 for (i = 1; i <= nnodes; i++) {
79 if (tin[current_id] == 0) {
82 stack[0] = current_node;
84 parent[current_id] =
NULL;
89 if (tin[node_id] == 0)
90 min_tin[node_id] = tin[node_id] = ++time;
96 if (min_tin[to] >= tin[node_id])
99 if (min_tin[to] < min_tin[node_id])
100 min_tin[node_id] = min_tin[to];
103 for (; current_edge[node_id]; current_edge[node_id] =
dglEdgeset_T_Next(¤t[node_id])) {
106 if (to == parent[node_id])
111 if (tin[to_id] < min_tin[node_id])
112 min_tin[node_id] = tin[to_id];
115 if (node_id == current_id)
117 parent[to_id] = node;
118 stack[stack_size++] = to;
122 if (!current_edge[node_id])
126 mark[current_id] = 1;
131 for (i = 1; i <= nnodes; i++)
138 for (i = 1; i <= nnodes; i++)
dglInt32_t * dglEdgeGet_Tail(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
void G_free(void *buf)
Free allocated memory.
int dglEdgeset_T_Initialize(dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
int dglNode_T_Initialize(dglNodeTraverser_s *pT, dglGraph_s *pGraph)
void dglNode_T_Release(dglNodeTraverser_s *pT)
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT)
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present.
dglInt32_t * dglNode_T_First(dglNodeTraverser_s *pT)
dglInt32_t * dglNodeGet_OutEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglGet_NodeCount(dglGraph_s *pgraph)
int NetA_articulation_points(dglGraph_s *graph, struct ilist *articulation_list)
Get number of articulation points in the graph.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
dglInt32_t * dglNode_T_Next(dglNodeTraverser_s *pT)
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)