-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
41 lines (31 loc) · 1.04 KB
/
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
/* graph.h - Header File
*
* Implementation of a graph structure.
*
* The graph contains two fields:
* "n" - representing the number of nodes in the graph
* "graph_nodes" - a list of the nodes values in the graph
*
* allocate_graph - Creates a new graph
* free_graph - Frees all the memory resources used by the graph
*/
#ifndef GRAPH_H_
#define GRAPH_H_
#include "spmat.h"
typedef struct _graph {
/*Number of vertices in the graph: |V| = n*/
int n;
/*List of the nodes in the graph, according to their initial value*/
int *graph_nodes;
void (*free_graph)(struct _graph* );
} graph;
/**
* Setting values to the inner fields of the pre-initialized graph structure (using dynamic allocation).
* If graph == NULL, throws an error and exits the program.
*
* @param graph - pointer to an pre- initialized graph.
* @param integer - the size of the graph (number of nodes).
* @param vector of integers - the graph's nodes list
*/
void allocate_graph(graph* , int , int* );
#endif