This app will help to visualize Dijsktra's algorithm using C++ and SFML (Graphic Library).
- The main.cpp will generate a graph including vertices and weighted edges. Then you will be asked to input 2 vertices that needs to find the shortest path.
cor.txt
will control the coordination of vertices on the graph.edge.txt
will control the weighted edges.
- Install SFML:
sudo apt-get install libsfml-dev
- Compile all .cpp file together:
g++ -c main.cpp -o main.o
- Link all the compiled files with the used library ( this project uses 3 libraries ):
g++ main.o Graph.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
- The executable file:
./sfml-app
g++ -c main.cpp -o main.o; g++ -c Graph.cpp -o Graph.o; g++ main.o Graph.o -o sfml.app -lsfml-graphics -lsfml-window -lsfml-system;
-
To change the graph randomly, run:
python3 random_gen.py
-
Then run the app again to see the new graph:
./sfml-app
- You might need to run it multiple times if the script does not give you a good randomized set for visualization purpose.
- cor_edge_sameple.txt is a test set if needed.