graph.h
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Graph routines */
#ifndef __GRAPH
#define __GRAPH
#include "list.h"
typedef struct sNode {
void *pContent;
tList OutEdges;
tList InEdges;
int bMark;
} tNode;
typedef struct sEdge {
tNode *pSrc;
tNode *pDest;
} tEdge;
typedef struct sGraph {
tList Nodes;
tList Edges;
} tGraph;
void Graph_Init(tGraph *pGraph);
tList *Graph_GetNodes(tGraph *pGraph);
tList *Graph_GetEdges(tGraph *pGraph);
int Graph_GetNumNodes(tGraph *pGraph);
int Graph_GetNumEdges(tGraph *pGraph);
tNode *Graph_AddNode(tGraph *pGraph, void *pContent);
tEdge *Graph_AddEdge(tGraph *pGraph, tNode *pSrc, tNode *pDest);
void Graph_RemoveEdge(tGraph *pGraph, tEdge *pEdge);
void Graph_UnmarkNodes(tGraph *pGraph);
int Graph_DepthFirstForward(tGraph *pGraph, tNode *pNode, tVisitFunc *pPreFunc, void *pPreArgs, tVisitFunc *pPostFunc, void *pPostArgs);
int Graph_DepthFirstBackward(tGraph *pGraph, tNode *pNode, tVisitFunc *pPreFunc, void *pPreArgs, tVisitFunc *pPostFunc, void *pPostArgs);
tNode *Graph_FindNode(tGraph *pGraph, void *pContent);
void Graph_CalcSccListList(tGraph *pGraph, tList *pListList);
void *Node_GetContent(tNode *pNode);
tList *Node_GetOutEdges(tNode *pNode);
tList *Node_GetInEdges(tNode *pNode);
int Node_GetOutDegree(tNode *pNode);
int Node_GetInDegree(tNode *pNode);
int Node_IsMarked(tNode *pNode);
tNode *Edge_GetSrcNode(tEdge *pEdge);
tNode *Edge_GetDestNode(tEdge *pEdge);
#endif