Giter Site home page Giter Site logo

nikhil-jindal12 / shortestpathalgorithm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 24 KB

Contains implementation for an airport system that uses Dijkstra's and Prim's Algorithm's to find the shortest paths.

Home Page: https://nikhil-jindal12.github.io/ShortestPathAlgorithm/

Java 100.00%
java-8 javadoc-documentation prim-algorithm dijkstra-algorithm

shortestpathalgorithm's Introduction

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<String, Vertex> 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<Edge> minimumSpanningTree() - creates a minimum spanning tree of the airport system using Prim's algorithm
  • List<String> 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.

shortestpathalgorithm's People

Contributors

nikhil-jindal12 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.