StreetGraph.NET 1.0.0

dotnet add package StreetGraph.NET --version 1.0.0
NuGet\Install-Package StreetGraph.NET -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="StreetGraph.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StreetGraph.NET --version 1.0.0
#r "nuget: StreetGraph.NET, 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.
// Install StreetGraph.NET as a Cake Addin
#addin nuget:?package=StreetGraph.NET&version=1.0.0

// Install StreetGraph.NET as a Cake Tool
#tool nuget:?package=StreetGraph.NET&version=1.0.0

StreetGraph.NET NuGet Version

Street Graphs in .NET Core. Includes Shortest Path, Journey Time

Get Started

Install the latest version from NuGet

  Install-Package StreetGraph.NET

Details

Graph is an object of type <INodeObject, IEdgeObject>, you can consider INodeObject as Camera Location and IEdgeObject as link between cameras which has a Distance, and Speed. Below example creates graph object using class StreetLocation and StreetLink.

Example

var g = new Graph<StreetLocation, StreetLink>();

g.AddNode(new StreetLocation() { Id = 1, LocationName = "location 1" });
g.AddNode(new StreetLocation() { Id = 2, LocationName = "location 2" });
g.AddNode(new StreetLocation() { Id = 3, LocationName = "location 3" });
g.AddNode(new StreetLocation() { Id = 4, LocationName = "location 4" });

g.Connect(1, 2, new StreetLink() { Distance = new Distance(500, DistanceUnit.Meters), Speed = new Speed(80, SpeedUnit.KilometersPerHour) });
g.Connect(1, 3, new StreetLink() { Distance = new Distance(600, DistanceUnit.Meters), Speed = new Speed(60, SpeedUnit.KilometersPerHour) });
g.Connect(2, 3, new StreetLink() { Distance = new Distance(0.2, DistanceUnit.Kilometers), Speed = new Speed(60, SpeedUnit.KilometersPerHour) });
g.Connect(2, 4, new StreetLink() { Distance = new Distance(450, DistanceUnit.Meters), Speed = new Speed(80, SpeedUnit.KilometersPerHour) });
g.Connect(3, 4, new StreetLink() { Distance = new Distance(400, DistanceUnit.Meters), Speed = new Speed(80, SpeedUnit.KilometersPerHour) });

// print graph locations and links
foreach (var locations in g)
{
    foreach (var link in locations)
    {
        Console.WriteLine(locations.Key + "->" + link.Node.Key + " (" + link.Object.Speed + ", " + link.Object.Distance + ")");
    }
}

// calculate shortest distance between 2 locations
var shortestPathResult = g.CalculateShortestPath(1, 4, ShortestPathCost.Distance);
Console.WriteLine("shortest distance: {0}", shortestPathResult.Distance);
Console.Write("path:");
foreach (var r in shortestPathResult.GetPath())
{
    Console.Write(r + "->");
}
Console.WriteLine();

// calculate speed using IRide object
var transitResult = g.CalculateTransitTime(new Ride() { NodeStart = 1, NodeEnd = 2, TimeStart = DateTime.Now, TimeEnd = DateTime.Now.AddSeconds(22.5) });
Console.WriteLine("transit speed: {0:0} Km/hr", transitResult.Speed.GetSpeed(SpeedUnit.KilometersPerHour));

// calculate speed using ITransit object
transitResult = g.CalculateTransitTime(new Trans() { Id = 1, TransitTime = DateTime.Now }, new Trans() { Id = 2, TransitTime = DateTime.Now.AddSeconds(22.5) });
Console.WriteLine("transit speed: {0:0} Km/hr", transitResult.Speed.GetSpeed(SpeedUnit.KilometersPerHour));

public class StreetLocation : INodeObject
{
    public int Id { get; set; }
    public string LocationName { get; set; }

    public override string ToString()
    {
        return $"StreetLocation({Id}, {LocationName})";
    }
}

public class StreetLink : IEdgeObject
{
    public Distance Distance { get; set; }
    public Speed Speed { get; set; }
    public Time Time { get; set; }

    public override string ToString()
    {
        return $"StreetLink({Distance}, {Speed})";
    }
}

public class Ride : IRide
{
    public int NodeStart { get; set; }
    public int NodeEnd { get; set; }
    public DateTime TimeStart { get; set; }
    public DateTime TimeEnd { get; set; }
}

public class Trans : ITransit
{
    public int Id { get; set; }

    public DateTime TransitTime { get; set; }
}

Code

https://github.com/rizansari/StreetGraph.NET

License

License

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

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. 
.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 463 7/2/2020