-
Notifications
You must be signed in to change notification settings - Fork 30
/
sparse_graph.h
56 lines (48 loc) · 1.11 KB
/
sparse_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
/**
* @file graph.h
*
* @author hutusi ([email protected])
*
* @brief Adjacency Matrix.
*
* @date 2019-07-21
*
* @copyright Copyright (c) 2019, hutusi.com
*
*/
#ifndef RETHINK_C_SPARSE_GRAPH_H
#define RETHINK_C_SPARSE_GRAPH_H
#include "arraylist.h"
typedef struct _AdjacencyArc AdjacencyArc;
typedef struct _AdjacencyList AdjacencyList;
typedef ArrayList SparseGraph;
/**
* @brief Malloc a new Sparse Graph.
*
* @param num_vertex The number of vertexes.
* @return SparseGraph* The new Sparse Graph.
*/
SparseGraph *sparse_graph_new(unsigned int num_vertex);
/**
* @brief Delete a Sparse Graph.
*
* @param graph The Sparse Graph.
*/
void sparse_graph_free(SparseGraph *graph);
/**
* @brief Link two vertexes in a Sparse Graph.
*
* @param graph The Sparse Graph.
* @param vertex1
* @param vertex2
* @return int
*/
int sparse_graph_link(SparseGraph *graph, int vertex1, int vertex2);
/**
* @brief Topological sorting by Khan algorithm.
*
* @param graph
* @return Queue*
*/
int *sparse_graph_topo_sort(SparseGraph *graph);
#endif /* #ifndef RETHINK_C_SPARSE_GRAPH_H */