Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikhil-jindal12/shortestpathalgorithm
Contains implementation for an airport system that uses Dijkstra's and Prim's Algorithm's to find the shortest paths.
https://github.com/nikhil-jindal12/shortestpathalgorithm
dijkstra-algorithm java-8 javadoc-documentation prim-algorithm
Last synced: 9 days ago
JSON representation
Contains implementation for an airport system that uses Dijkstra's and Prim's Algorithm's to find the shortest paths.
- Host: GitHub
- URL: https://github.com/nikhil-jindal12/shortestpathalgorithm
- Owner: nikhil-jindal12
- Created: 2023-12-05T22:29:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-22T01:57:24.000Z (about 1 year ago)
- Last Synced: 2024-11-13T04:13:27.743Z (2 months ago)
- Topics: dijkstra-algorithm, java-8, javadoc-documentation, prim-algorithm
- Language: Java
- Homepage: https://nikhil-jindal12.github.io/ShortestPathAlgorithm/
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ShortestPathAlgorithm
This repository contains two classes: `AirportSystem.java` and `AirportSystemTesting.java`. These two classes create a fake airport system/graph that organizes and creates an application with the following functionalities:
- Create an airport system that stores the city connection information
- Finds the shortest path from city A to city B using Dijkstra's algorithm
- Finds the minimum spanning tree of a graph using Prim's algorithm----
### Implementation
#### Edge
Edge is a private nested class of `AirportSystem.java` that contains the following:
- `String toString()` - the String representation of the edge in the format of "[start, destination]"#### Vertex
Vertex is another private nested class of `AirportSystem.java` that contains the following implementation:
- `String toString()` - the String representation of the vertex in the format of "id"#### AirportSystem
- `HashMap connections` - an adjacency list of all of the flight connections
- `boolean addEdge(String source, String destination, int weight)` - adds a new edge to the connections list, returning false if the edge already exists or the weight is negative
- `int shortestDistance(String cityA, String cityB)` - returns the shortest distance between cityA and cityB using Dijkstra's algorithm
- `List minimumSpanningTree()` - creates a minimum spanning tree of the airport system using Prim's algorithm
- `List breadthFirstSearch(String start)` - returns a list of all of the cities from the starting city using BFS, assuming that the start vertex exists
- `void printGraph()` - prints the graph in a readable format to the terminal window----
### JUnit Testing
The `AirportSystemTesting.java` class contains some JUnit tests for the `shortestDistance()` method and the `minimumSpanningTree()` method. All of the tests pass, which proves that both Dijkstra's and Prim's Algorithms are coded properly.