This repository contains an implementation of Dijkstra's Algorithm in C++.
$ git clone https://github.com/Alpaca-zip/dijkstra_algorithm.git
$ sudo apt-get install -y libboost-all-dev
$ bash build.sh
You will be prompted to input the number of nodes, the number of edges, and the source node. For each edge, you should specify the source node, the destination node, and the weight of the edge. The program will calculate and print the shortest distance from the source node to all other nodes.
$ bash run.sh
Enter the number of nodes: 5
Enter the number of edges: 7
Enter the source of node: 0
Enter edge 1 (source, destination, weight): 0 1 7
Enter edge 2 (source, destination, weight): 0 2 4
Enter edge 3 (source, destination, weight): 0 3 3
Enter edge 4 (source, destination, weight): 1 2 1
Enter edge 5 (source, destination, weight): 1 4 2
Enter edge 6 (source, destination, weight): 2 4 6
Enter edge 7 (source, destination, weight): 3 4 5
========== RESULT ==========
Node Distance from Source
0 0
1 5
2 4
3 3
4 7
Saving graph...
Done.
![](https://private-user-images.githubusercontent.com/84959376/253617739-cf02d929-a46f-46b1-b935-4193ed38787d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4NDA0NTAsIm5iZiI6MTcyNTg0MDE1MCwicGF0aCI6Ii84NDk1OTM3Ni8yNTM2MTc3MzktY2YwMmQ5MjktYTQ2Zi00NmIxLWI5MzUtNDE5M2VkMzg3ODdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA5VDAwMDIzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5ZWUxMTlmMzFhM2ZkYjhhNDM1MDljYTQ2YTU1ZGY1ZTE4Nzg4YjhjNjhiYzViNTIwYjNiZGFkZjVhMTkxN2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.qM5by8y4tsFx0i4dxh0T9a1CUKJoQRfQXvekRx_dauQ)