IRI.Maptor.Core.Graph
3.0.0
dotnet add package IRI.Maptor.Core.Graph --version 3.0.0
NuGet\Install-Package IRI.Maptor.Core.Graph -Version 3.0.0
<PackageReference Include="IRI.Maptor.Core.Graph" Version="3.0.0" />
<PackageVersion Include="IRI.Maptor.Core.Graph" Version="3.0.0" />
<PackageReference Include="IRI.Maptor.Core.Graph" />
paket add IRI.Maptor.Core.Graph --version 3.0.0
#r "nuget: IRI.Maptor.Core.Graph, 3.0.0"
#:package IRI.Maptor.Core.Graph@3.0.0
#addin nuget:?package=IRI.Maptor.Core.Graph&version=3.0.0
#tool nuget:?package=IRI.Maptor.Core.Graph&version=3.0.0
IRI.Maptor.Core.Graph
Graph data structures and algorithms for the Maptor stack, inspired by the graph chapters of CLRS (Introduction to Algorithms). Supports directed and undirected weighted graphs with the classic traversal, shortest-path, spanning-tree, and connectivity algorithms.
Installation
dotnet add package IRI.Maptor.Core.Graph
Features
- Adjacency-list representation (
AdjacencyList<TNode, TWeight>) with directed and undirected weighted edges, plus aDirectedAcyclicGraphtype; matrix-based algorithm variants accept aMatrixadjacency input - Traversal: breadth-first search (
BreadthFirstSearch) and depth-first search (DepthFirstSearch,FastDepthFirstSearch) with topological sort and cycle detection - Shortest paths: Dijkstra (
DijkstraProblem, adjacency-matrix input), Bellman-Ford (BellmanFordProblem,BellmanFordMatrixProblem; handles negative weights and detects negative cycles), Floyd-Warshall all-pairs (FloydWarshallProblem) - Minimum spanning tree: Kruskal (
MinimumSpanningTree.CalculateByKruskal) and Prim (PrimAlgorithm) - Strongly connected components (
GraphHelper.GetStronglyConnectedComponents) - Minimum cut (
MinimumCut.GetMinCut) and greedy clustering (GreedyClustering)
Usage
Build a graph and run BFS:
using IRI.Maptor.Core.Graph;
var g = new AdjacencyList<string, int>();
g.AddDirectedEdge("A", "B", 1);
g.AddDirectedEdge("A", "C", 1);
g.AddDirectedEdge("B", "D", 1);
g.AddDirectedEdge("C", "D", 1);
var bfs = new BreadthFirstSearch<string, int>(g, startNode: "A");
double level = bfs.GetLevel("D"); // 2
var path = bfs.GetPathTo("D"); // ["A", "B", "D"] or ["A", "C", "D"]
Bellman-Ford with negative weights:
var graph = new AdjacencyList<string, double>();
graph.AddDirectedEdge("A", "B", 4.0);
graph.AddDirectedEdge("B", "C", -3.0); // negative weight allowed
graph.AddDirectedEdge("C", "D", 5.0);
var bellmanFord = new BellmanFordProblem<string, double>(graph, "A");
if (!bellmanFord.HasNegativeCycle)
{
double distance = bellmanFord.GetDistance("D");
var path = bellmanFord.GetShortestPath("D");
}
Minimum spanning tree and strongly connected components:
var ug = new AdjacencyList<string, int>();
ug.AddUndirectedEdge("A", "B", 4);
ug.AddUndirectedEdge("A", "C", 1);
ug.AddUndirectedEdge("B", "C", 3);
var mstKruskal = MinimumSpanningTree.CalculateByKruskal<string, int>(ug);
var mstPrim = new PrimAlgorithm<string, int>(ug).GetMinimumSpanningTree();
// each inner list is one strongly connected component of a directed graph
var components = GraphHelper.GetStronglyConnectedComponents<string, int>(g);
See also
| Product | Versions 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.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- IRI.Maptor.Core.Common (>= 3.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on IRI.Maptor.Core.Graph:
| Package | Downloads |
|---|---|
|
IRI.Maptor.Core.Spatial
A .NET standard library to work with spatial types, structures and algorithms (GeoJson, Geometry, KdTree, RTree, Delaunay, Simplification, etc.) |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 253 | 8/23/2026 |
| 3.0.0-alpha | 245 | 8/22/2026 |