-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.h
68 lines (54 loc) · 914 Bytes
/
graph.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef GRAPH_H
#define GRAPH_H
#define GRAPH_INCREMENT 16
typedef struct vertex
{
/**
* Whatever you want.
*/
void *data;
/**
* Size of the data stored in data.
*/
int alloc;
/**
* The index identifying the vertex.
*/
int id;
/**
* The number of neighbors.
*/
int degree;
/**
* Flag set to 1 if the back pointer is set, 0 otherwise.
*/
char bflag;
/**
* Use when doing DFS or BFS; indicates the path taken to current vertex.
*/
struct vertex *back;
/**
* List of neighboring vertices.
*/
struct vertex *neighbors;
} vertex_t;
typedef struct graph
{
/**
* The total number of vertices.
*/
int nvert;
/**
* The total number of edges.
*/
int nedge;
/**
* The number of bytes to allocate for each vertex's data.
*/
int step;
/**
* Pointer to the first vertex.
*/
vertex_t *vertex; /* the pointer to the first vertex */
} graph_t;
#endif