-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
44 lines (33 loc) · 1.01 KB
/
main.c
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
#include "./include/main.h"
int main() {
char *path = "./files/test.txt";
char **lines = NULL;
int **matrix = NULL;
int matrix_size = 0;
int vertices_number = 0;
int edges_number = 0;
tGraph *graph = NULL;
lines = readLinesFromFile(path);
matrix = parseSquareMatrix(lines);
matrix_size = getMatrixSize(lines);
vertices_number = matrix_size;
for (int i = 0; i < matrix_size; i++) {
for (int j = 0; j <= i; j++) {
if (matrix[i][j] != 0)
edges_number++;
}
}
graph = initializeGraph(vertices_number, edges_number);
graph = createGraph(graph, matrix);
bool *visited_vertices = (bool*) calloc(graph->vertices_n, sizeof(bool));
dfsGraph(graph, 0, visited_vertices);
if (isConnectedGraph(graph, visited_vertices)) {
puts("Connected graph");
} else {
puts("Disconected graph");
}
showGraph(graph);
free(visited_vertices);
delGraph(&graph);
return 0;
}