Here, I have used Breadth-First-Search Algorithm to find the shortest path. Other famous algorithms for the same are Bellman-Ford and Floyd-Warshall.
Mention the following as command line arguments (k is an integer):
*-s k : The number of streets, default k = 10 and k >= 2
*-n k : The number of line segments in each street, default k = 5 and k >= 1
*-l k : Wait time in seconds before generating next random street, default k = 5 and k >= 5
*-c k : Coordinates generated in the range of [-k,k], default k = 15
A random generator (rgen) generates streets based on above specifications.
I used pipes to connect following processes (Inter-Process communication):
- A process between Rgen that generated streets(Vertices and Edges) and graphgen that validates the commands from rgen and outputs a graph.
- A process that reads output of graphgen and reads user input to find shortest distance between two vertices.
Use below commands in shell:
$ mkdir build
$ cd build
$ make install
$ cd ./run/bin
$ ./a3-ece650 -s 5 -n 4 -l 5
V 8
E {<0,2>,<0,3>,<0,4>,<1,3>,<4,7>,<5,2>,<5,6>}
s 2 4 ----> user input
2-0-4 ----> shortest path