Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

This repository contains an implementation of Dijkstra's Algorithm in C++.

License

Notifications You must be signed in to change notification settings

Alpaca-zip/dijkstra_algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dijkstra_algorithm Ubuntu-latest Build Check

This repository contains an implementation of Dijkstra's Algorithm in C++.

How to Use

1. Clone this repository.

$ git clone https://github.com/Alpaca-zip/dijkstra_algorithm.git

2. Install dependencies and compile the program.

$ sudo apt-get install -y libboost-all-dev
$ bash build.sh

3. Run the program.

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.

4. The results will be saved as graph.pdf.

About

This repository contains an implementation of Dijkstra's Algorithm in C++.

Topics

Resources

License

Stars

Watchers

Forks