This C++ program implements Prim's algorithm to find the Minimum Spanning Tree (MST) of a given graph. It's perfect for network design, optimizing connections, or solving various graph-related problems!
- ๐ Build custom graphs with nodes and weighted edges
- ๐ Find the Minimum Spanning Tree using Prim's algorithm
- ๐ Calculate the total weight of the MST
- ๐จ๏ธ Print the path coordinates and distances
- Ensure you have a C++ compiler installed (e.g., g++)
- Clone this repository:
git clone https://github.com/Sandheep-S-95/OptiRoute-Pro.git - Navigate to the project directory:
cd OptiRoute-Pro - Compile the program:
g++ main.cpp
-
Run the compiled program:
./main.cpp -
Follow the prompts to input your graph data:
- Enter the number of nodes
- Enter the names of each node
- Enter the number of edges
- For each edge, enter the source node, destination node, and weight
-
The program will output the Minimum Spanning Tree and its total weight.
Enter the number of nodes: 4
Enter node names:
A B C D
Enter the edges and weights (from to weight):
6
A B 5
B C 3
C D 2
D A 4
A C 7
B D 6
From: C To: D Distance: 2
From: B To: C Distance: 3
From: A To: B Distance: 5
Total Minimum Spanning Tree Weight: 10
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.
- Thanks to all contributors and users of this project!
- Inspired by graph theory and the beauty of efficient algorithms.
Happy Route optimizing! ๐