-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.h
39 lines (27 loc) · 854 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
#ifndef __GRAPH_H__
#define __GRAPH_H__
typedef struct {
int from;
int to;
int cost;
} edge_t;
typedef struct {
edge_t *edges;
int num_edges;
int capacity;
int num_nodes;
} graph_t;
/* Allocate a new graph and return a reference to it. */
graph_t* allocate_graph();
/* Free all allocated memory and set reference to the graph to NULL. */
void free_graph(graph_t **graph);
graph_t* enlarge_graph(graph_t *g);
/* Load a graph from the text file. */
void load_txt(const char *fname, graph_t *graph);
/* Load a graph from the binary file. */
void load_bin(const char *fname, graph_t *graph);
/* Save the graph to the text file. */
void save_txt(const graph_t * const graph, const char *fname);
/* Save the graph to the binary file. */
void save_bin(const graph_t * const graph, const char *fname);
#endif // __GRAPH_H__