Giter VIP home page Giter VIP logo

dijkstra's Introduction

dijkstra TS

Sample Graph

A glorified dijkstra implementation(s) using TypeScript with multiple data structures.

This repo is for educational purposes. Graphs can be easily visualized using PlantUML.

Setup

    npm install

The entry points

  • appPrim.ts creates a predetermined graph and generates the minimum spanning graph and then traverses several use cases with the shortest path.
  • appPrimLoad.ts This variant loads ./sample-graphs/graph1.json as the input graph.
  • appPrimRandom.ts This variant generates a random input graph.

All outputs of the runs go under the temp folder graphs. Use the IDE plugin to open plantuml files or copy/paste the result of .puml into their website.

Each entry point, when run, generates it's input/mst graphs under ./graphs.

Figuring out the next cheapest path

  • There are two data structures that can do that
    • HeapRunningCosts: Uses a heap structure to achieve O(Edge * Log(Vertex))
    • LinearRunningCosts: Uses an array structure to achieve O(VertexΒ²)

All entry points can be run using with the env variable USE_HEAP_STRUCTURE=TRUE to use the heap.

If using the heap, you can optionally use FIND_LONGEST_PATH=TRUE to use max heap. This will find the longest path instead of the shortest path

Samples

Checkout the samples.

Graphing support

  • I use PlantUM to enable drawing graphs easily. You need to have GraphViz.

dijkstra's People

Contributors

ralphv avatar

Stargazers

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