GithubHelp home page GithubHelp logo

fouadroumieh / shortest-path-dijkstra-algorithm Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 40 KB

An example on showing how to find the shortest path in a weighted network.

C# 100.00%
csharp algorithm-challenges data-structures dijkstra-shortest-path

shortest-path-dijkstra-algorithm's Introduction

Shortest path Dijkstra Algorithm

An example on showing how to find the shortest path in a weighted network graph. Solution: Visual Studio 2015 Project with no 3rd party dependency.

For all paths we assumed that we can only repeat the first city at the end of the path to close the cycle

We based all on a graph class which contains two representations of the graph. An adjacency matrix and an adjacency list. The adjacency matrix is used to check if a path is valid (and compute its length). and the adjacency list is used for Dijkstra algorithm (shortest path) and for computing the number of different routes in different questions. For Dijkstra algorithm we implemented a priority queue class based on heaps.

The graph input is stored in a file "Data/network.txt" with the following format:

  • Buenos Aires > New York = 6 days
  • Buenos Aires > Casablanca = 5 days
  • Buenos Aires > Cape Town = 4 days
  • New York > Liverpool = 4 days
  • Liverpool > Casablanca = 3 days
  • Liverpool > Cape Town = 6 days
  • Casablanca > Liverpool = 3 days
  • Casablanca > Cape Town = 6 days
  • Cape Town > New York = 8 days

Additional routes can be added. Also the direct routes are in "Data/routes.txt"

Also the shortest path are in "Data/shortestPath.txt"

The unit test project is self explanatory with the test cases names. It covers the questions and some other related to input errors.

shortest-path-dijkstra-algorithm's People

Contributors

fouadroumieh avatar

Watchers

 avatar  avatar  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.