-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
33 lines (24 loc) · 867 Bytes
/
main.c
File metadata and controls
33 lines (24 loc) · 867 Bytes
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
#include "dijkstra_calculator.h"
#include "graph_file_creator.h"
int main() {
FILE *fp = fopen("/tmp/graph.txt", "r");
if (NULL == fp) {
perror("Error in opening file");
return -1;
}
graph G = GRAPH_FILE_CREATOR_create_graph(fp);
printf("Number of vertices is %d\n", GRAPH_get_number_of_vertices(G));
printf("Number of edges is %d\n", GRAPH_get_number_of_edges(G));
graph_vertex_id_t source = 1;
graph_vertex_id_t target = 5;
dijkstra_calculator_t calculator;
DIJKSTRA_CALC_set_source_id(&calculator, source);
DIJKSTRA_CALC_set_target_id(&calculator, target);
DIJKSTRA_CALC_set_graph_and_init(&calculator, G);
DIJKSTRA_CALC_run(&calculator);
DIJKSTRA_CALC_output_results(&calculator);
DIJKSTRA_CALC_clean_sources(&calculator);
GRAPH_destroy(G);
fclose(fp);
return 0;
}