Eternity0707/Shortest-Path-Algorithm-with-Heaps
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Running Instructions Overview: This program compares the performance of Fibonacci Heap and Binary Heap in executing Dijkstra's algorithm. The program reads .gr format graph data files from a specified folder, applies both heap implementations to Dijkstra's algorithm, and records the computation time for the shortest path between pairs of nodes. The results are saved in a report file called dijkstra_comparison_report.txt. Environment Requirements: The program uses the dirent.h library to traverse the directory, so it must be run in a macOS or Linux environment. Windows users, if they wish to run the program, must modify the directory traversal code or run it in an environment that supports POSIX standards (such as using Cygwin or WSL). Compilation: Open the terminal and navigate to the directory where the program is located. Ensure that you have a C compiler installed, such as gcc or any compatible C compiler. Use the following command to compile the program: gcc main.cpp fibonacciheap.cpp fibonacci_dijkstra.cpp binaryheap.cpp -o main Steps to Run: Preparation: Prepare .gr formatted graph data files and store them in the specified folder. Run the Program: After executing the program, it will prompt you to enter the folder path containing .gr files. Upon entering the path, the program will automatically scan the folder and read all .gr files. Testing Process: For each .gr file, the program generates 100 pairs of random nodes (source and target). For each node pair, the program runs Dijkstra's algorithm using both Fibonacci Heap and Binary Heap, recording the execution time. The test results for each pair of nodes are recorded in the report file, showing the time taken for each heap implementation (in milliseconds). Report Generation: All test results will be saved in the dijkstra_comparison_report.txt file. Each test result will show the source node and target node, with the execution times for both Fibonacci Heap and Binary Heap. Final Output: The test results for each file will display the execution times for both Fibonacci Heap and Binary Heap. Finally, the average execution times for both heap algorithms will be output. Notes: Ensure the graph data files are valid .gr format and conform to the specified format. The program will test 100 node pairs for each .gr file, so the testing time may be longer. The execution time is recorded in milliseconds (ms), and the report will list the computation times for each node pair. Requires macOS or Linux environment. Windows users need to modify the directory traversal code or run it in a POSIX-compatible environment (e.g., using Cygwin or WSL).