-
Notifications
You must be signed in to change notification settings - Fork 1
/
edge_disjoint.c
65 lines (58 loc) · 1.74 KB
/
edge_disjoint.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "edge_disjoint.h"
int main(int argc, char *argv[]){
int i;
total_nodes = -1;
int src,dest;
if(argc != 4){
perror("Incorrect command line arguments\n");
exit(-1);
}
file = fopen(argv[1],"r");
//printf("Before Init\n");
initialize_topology();
//printf("After Init\n");
src = atoi(argv[2])-1;
dest = atoi(argv[3])-1;
printf("Src: %d, Dest: %d ->\n",src + 1,dest + 1);
if(src >= total_nodes || dest >= total_nodes || src < 0 || dest < 0){
printf("Source or Destination out of bounds. Exiting..\n\n");
exit(1);
}
else if(src == dest){
printf("Source and Destination are Same. Exiting..\n\n");
exit(1);
}
//Edge Disjoint Steps
//printf("Before\n");
modified_dijkstra(src); //Source to Dest Path
//printf("Afer Dijkstra 1\n");
save_path(src,dest,0); //Save Path, Revert Edges, -ve cost
//print_shortest_path(0);
//printf("Afer Save Path 1\n");
reset_topology();
//printf("After Reset\n");
if(!modified_dijkstra(src)){ //Run djkstra on the Updated *node Graph
print_shortest_path(0);
printf("No Pair of Shortest path exist. Exiting..\n\n");
exit(1);
}
//printf("Afer Dijkstra 2\n");
save_path(src,dest,1);
//printf("Afer Save Path 2\n");
//print_shortest_path(0);
//print_shortest_path(1);
//print_path(src,dest);
find_interlace();
//save path for all paths
//printf("After Interlace\n");
print_shortest_path(0);
print_shortest_path(1);
printf("\n");
for(i=0;i<total_nodes;i++)
{
free(node[i].edge_cost);
// free(node[i].saved_cost);
// free(node[i].next_hop);
}
free(node);
}