DijkstraAlgorithm.NetCore 1.0.0

dotnet add package DijkstraAlgorithm.NetCore --version 1.0.0
                    
NuGet\Install-Package DijkstraAlgorithm.NetCore -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DijkstraAlgorithm.NetCore" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DijkstraAlgorithm.NetCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DijkstraAlgorithm.NetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DijkstraAlgorithm.NetCore --version 1.0.0
                    
#r "nuget: DijkstraAlgorithm.NetCore, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DijkstraAlgorithm.NetCore@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DijkstraAlgorithm.NetCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DijkstraAlgorithm.NetCore&version=1.0.0
                    
Install as a Cake Tool

Dijkstra Algorithm

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph. wikipedia

Github URL

https://github.com/marusi/DijkstraAlgorithm

Nuget Packages

Nuget Package Name Nuget Package URL
DijkstraAlgorithm COMING SOON

Example Usage

// Create graph --- new object from GraphBuilder Class
var newGraph = new GraphBuilder();
// add node or vertices: Tokyo, Moscow, Berlin, Nairobi, Rio, Denver, Helsinki, and Oslo.
newGraph.AddNode("Nairobi"); //a
newGraph.AddNode("Tokyo");   //b
newGraph.AddNode("Moscow");  // c
newGraph.AddNode("Berlin");  //d
newGraph.AddNode("Rio");     //e
newGraph.AddNode("Denver");  //f
newGraph.AddNode("Helsinki"); //g
newGraph.AddNode("Oslo");    //h

// Link Added and its relative cost
// newGraph.AddLink("Origin", "Destination", cost.inDouble... ) if you prefer decimal... later convert to double

newGraph
    .AddLink("Nairobi", "Tokyo", 600)
    .AddLink("Nairobi", "Berlin", 100);

newGraph
    .AddLink("Tokyo", "Nairobi", 600)
    .AddLink("Tokyo", "Moscow", 500)
    .AddLink("Tokyo", "Berlin", 200)
    .AddLink("Tokyo", "Rio", 200);

builder
    .AddLink("Moscow", "Tokyo", 500)
    .AddLink("Moscow", "Rio", 500);

builder
    .AddLink("Berlin", "Nairobi", 100)
    .AddLink("Berlin", "Tokyo", 200)
    .AddLink("Berlin", "Rio", 100);

builder
    .AddLink("Rio", "Tokyo", 200)
    .AddLink("Rio", "Moscow", 500)
    .AddLink("Rio", "Berlin", 100);

// call the Build Method
var graph = newGraph.Build();

// Create path finder
var pathFinder = new PathFinder(graph);

// Find path
const string origin = "Nairobi", destination = "Moscow";

var path = pathFinder.FindShortestPath(
    graph.Nodes.Single(node => node.Id == origin),
    graph.Nodes.Single(node => node.Id == destination));

// Assert results
Assert.Equal(path.Origin.Id, origin);
Assert.Equal(path.Destination.Id, destination);
Assert.Equal(path.Segments.Count, 300);
Assert.Equal(path.Segments.Sum(s => s.Weight), 700);

Assert.Equal(path.Segments.ElementAt(0).Origin.Id, "Nairobi");
Assert.Equal(path.Segments.ElementAt(0).Weight, 100);
Assert.Equal(path.Segments.ElementAt(0).Destination.Id, "Berlin");

Assert.Equal(path.Segments.ElementAt(1).Origin.Id, "Berlin");
Assert.Equal(path.Segments.ElementAt(1).Weight, 100);
Assert.Equal(path.Segments.ElementAt(1).Destination.Id, "Rio");

Assert.Equal(path.Segments.ElementAt(2).Origin.Id, "Rio");
Assert.Equal(path.Segments.ElementAt(2).Weight, 500);
Assert.Equal(path.Segments.ElementAt(2).Destination.Id, "Moscow");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 59,285 7/12/2020