Coder Social home page Coder Social logo

dijkstra-s-algorithm's Introduction

*****Introduction:

Given two points on a graph, the shortest path between them is the straight line that joins them. However, drawing a straight line may not always be possible. For example, in a road network, straight roads between two cities seldom exist. In such a case, there might be multiple routes between the two cities, and the challenge then is to find the shortest one.

Dijkstra’s algorithm helps us find the shortest path between a source node and every other node in a graph.

The algorithm is ubiquitous. For example, it is used in computer networking where it ascertains the shortest path between the source router and other routers in the network. Also, each time we are navigating via google maps, complex algorithms based on Dijkstra are being used to provide us with the best route.

****Implementing Dijkstra’s algorithm

In this short project, we implement Dijkstra’s algorithm. We have been provided with data and some code for a GUI, which generates a map of cities in the US and the different connections between them. Our goal is to compute for the user, the shortest path between any two cities they select on the map.

****Files submitted and respective descriptions

---Dijkstra.java - This is a file which contains the code for implementing Dijkstra’s shortest path algorithm.

---Display.java, Edge.java, Vertex.java - These files were provided to us with some existing code. We need these to create instances of the vertex object, edge object and implement relevant methods in the Dijkstra.java file. The Display.java file is required to run the GUI. NO CHANGES HAVE BEEN MADE TO THESE files.

---citypairs.txt, cityxy.txt - These are files provided to us with the data. NO CHANGES HAVE BEEN MADE TO THESE files. The cityxy.txt file contains a list of cities and their (X,Y) coordinates on the map. These are the vertices in the graph. The citypairs.txt lists direct, connections between pairs of cities. These links are bidirectional, if you can go from NewYork to Boston, you can get from Boston to New York. These are the edges of the graph.

Instructions to execute the program** Go the command line and navigate to the local directory which has all the files in this repository. Now, compile all java sources in the directory by typing javac 'filename'.java. Then run Display.java by typing java Display. This will launch the GUI. Now click on the appropriate buttons to test the corresponding methods.

dijkstra-s-algorithm's People

Contributors

daanishraj avatar

Stargazers

Dominik Pająk avatar Lucas Junqueira Bastos da Silva avatar Ali Arda İsenkul avatar

Watchers

 avatar

Forkers

idakun

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.