GithubHelp home page GithubHelp logo

dijkstra.net's Introduction

Dijkstra.NET NuGet Version

Dijkstra algorithm which use priority queue thus complexity is equal O(ElogV) where E is number of edges and V is number of vertices. Used data structures are based on interfaces so you can implement your own or reused present. Simply example below. More information about algorithm you can find on Wikipedia.

Get Started

Install the latest version from NuGet

  Install-Package Dijkstra.NET

Simple example

using Dijkstra.NET.Graph;
using Dijkstra.NET.ShortestPath;

var graph = new Graph<int, string>();

graph.AddNode(1);
graph.AddNode(2);

graph.Connect(1, 2, 5, "some custom information in edge"); //First node has key equal 1

ShortestPathResult result = graph.Dijkstra(1, 2); //result contains the shortest path

var path = result.GetPath();

or

using Dijkstra.NET.Graph;
using Dijkstra.NET.ShortestPath;

var graph = new Graph<int, string>() + 1 + 2;

bool connected = graph >> 1 >> 2 >> 5 ^ "custome edge information"; 

ShortestPathResult result = graph.Dijkstra(1, 2); //result contains the shortest path

var path = result.GetPath();

Benchmark

For Graph where number of nodes is 1 000 000 and connections between them 1 000 000. The length of path is minimum 10.

BenchmarkDotNet=v0.10.10, OS=Windows 10.0.17134
Processor=Intel Core i7-4700HQ CPU 2.40GHz (Haswell), ProcessorCount=8
Frequency=2338342 Hz, Resolution=427.6534 ns, Timer=TSC
  [Host]     : .NET Framework 4.6.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3260.0
  Job-XQYAYC : .NET Framework 4.6.1 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3260.0

LaunchCount=1  RunStrategy=Monitoring  TargetCount=3  
WarmupCount=2  
Method Mean Error StdDev Scaled ScaledSD Gen 0 Gen 1 Allocated
Dijkstra 7.515 ms 3.845 ms 0.2173 ms 1.00 0.00 - - 48 KB
PageRank 1,139.983 ms 762.417 ms 43.0780 ms 151.77 5.86 40000 40000 272365.8 KB

License

License

Dijkstra.NET is licensed under the MIT license. See LICENSE file for full license information.

dijkstra.net's People

Contributors

matiii avatar ridicoulous avatar

Watchers

 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.