Git Product home page Git Product logo

dijkstra's Introduction

Dijkstra in Clojure

This was implemented twice. The implementations differ in how they determine which node to explore next (that is, which node has the shortest distance, so far).

with_array_walk.clj

Uses an array walk to find the next node to explore.

Time complexity:

O(|V|^2) |V| = number of vertices in graph

with_fibonacci_heap.clj

Uses a Fibonacci heap to find the next node to explore.

Fibonacci heaps were developed for use with Dijkstra in 1984 by Fredman and Tarjan (http://www.computer.org/portal/web/csdl/doi/10.1109/SFCS.1984.715934).

Time complexity:

O(|E| + |V|log|V|) |E| = number of edges in graph |V| = number of vertices in graph

Outcome

In fact, the Fibonacci heap implementation takes about twice as long to run as the array walk implementation. It is suspected that this is because the Fibonacci heap implementation does a heap walk to find each node for which a shorter distance has just been found.

If the implementation had used a language with mutable data, it would have been possible to store references that linked nodes in the graph data structure to their corresponding nodes in the heap. However, with Clojure's immutable data, this seemed impossible. Zippers are fine to traverse individual data structures (and this is what is used to traverse the graph and the heap), but they cannot traverse across data structures.

dijkstra's People

Contributors

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