IRI.Maptor.Sta.Graph 2.7.4

dotnet add package IRI.Maptor.Sta.Graph --version 2.7.4
                    
NuGet\Install-Package IRI.Maptor.Sta.Graph -Version 2.7.4
                    
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="IRI.Maptor.Sta.Graph" Version="2.7.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IRI.Maptor.Sta.Graph" Version="2.7.4" />
                    
Directory.Packages.props
<PackageReference Include="IRI.Maptor.Sta.Graph" />
                    
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 IRI.Maptor.Sta.Graph --version 2.7.4
                    
#r "nuget: IRI.Maptor.Sta.Graph, 2.7.4"
                    
#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 IRI.Maptor.Sta.Graph@2.7.4
                    
#: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=IRI.Maptor.Sta.Graph&version=2.7.4
                    
Install as a Cake Addin
#tool nuget:?package=IRI.Maptor.Sta.Graph&version=2.7.4
                    
Install as a Cake Tool

IRI.Maptor.Sta.Graph

The IRI.Maptor.Sta.Graph library provides a set of graph data structures and algorithms inspired by the Graph chapter of the classic CLRS (Introduction to Algorithms) book.
It supports directed and undirected graphs, weighted graphs, and implements core algorithms for traversal, shortest paths, and more.


✅ Features

  • Graph representation: Adjacency List and Adjacency Matrix
  • Traversal algorithms:
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
  • Shortest path algorithms:
    • Dijkstra
    • Floyd Warshall
  • Minimum spanning tree:
    • Prim
  • Strongly Connected Components (SCC)
  • Utility functions for graph creation and manipulation

✅ Installation

Add the library to your .NET project:

dotnet add package IRI.Maptor.Sta.Graph

Or via NuGet package manager:

Install-Package IRI.Maptor.Sta.Graph

✅ Basic Usage

1. Create a Simple Graph

 
using IRI.Maptor.Sta.Graph;

// TNode can be any comparable key (e.g., string, int)
// TWeight must be IComparable (e.g., int, double)
var g = new AdjacencyList<string, int>();

// Directed edges
g.AddDirectedEdge("A", "B", 1);
g.AddDirectedEdge("A", "C", 1);
g.AddDirectedEdge("B", "D", 1);
g.AddDirectedEdge("C", "D", 1);


Breadth-First Search (BFS)

// Start BFS from source "A"
var bfs = new BreadthFirstSearch<string, int>(g, startNode: "A");

// Distance (level) from A to D
double level = bfs.GetLevel("D"); // 2

// Reconstruct a shortest path from A to D
var path = bfs.GetPathTo("D");    // ["A", "B", "D"] or ["A", "C", "D"]

// The BFS tree discovered from A (as an adjacency list)
var bfsTree = bfs.searchResult;

Depth-First Search (DFS) & Topological Sort

// Build a small DAG
var dag = new AdjacencyList<string, int>();
dag.AddDirectedEdge("5", "2", 1);
dag.AddDirectedEdge("5", "0", 1);
dag.AddDirectedEdge("4", "0", 1);
dag.AddDirectedEdge("4", "1", 1);
dag.AddDirectedEdge("2", "3", 1);
dag.AddDirectedEdge("3", "1", 1);

// Run DFS (start node can be any existing node)
var dfs = new DepthFirstSearch<string, int>(dag, startNode: "5");

// Topological order (method name as implemented in the code)
var topo = dfs.CalculateTopologiacalSort(); // e.g., ["4","5","2","3","1","0"]

// Get nodes sorted by finish time, if needed:
var finishOrder = dfs.GetSortedNodes(SortType.BasedOnFinishTime);

// Is the original graph cyclic?
bool hasCycle = dfs.IsOriginalGraphCyclic; // should be false for a DAG

Strongly Connected Components (SCC)

// For a directed graph g:
var components = Graph.GetStronglyConnectedComponents<string, int>(g);

// components is List<List<string>>;
// each inner list is one strongly connected component.

Minimum Spanning Tree (MST)

Build an undirected weighted graph and compute MSTs with Kruskal or Prim.

var ug = new AdjacencyList<string, int>();
ug.AddUndirectedEdge("A", "B", 4);
ug.AddUndirectedEdge("A", "C", 1);
ug.AddUndirectedEdge("B", "C", 3);
ug.AddUndirectedEdge("B", "D", 2);
ug.AddUndirectedEdge("C", "D", 5);

// Kruskal
var mstKruskal = MinimumSpanningTree.CalculateByKruskal<string, int>(ug);

// Prim
var prim = new PrimAlgorithm<string, int>(ug);
var mstPrim = prim.GetMinimumSpanningTree();

✅ Algorithms Implemented

Algorithm Description
BFS Breadth-First Search traversal
DFS Depth-First Search traversal
Dijkstra Single-source shortest path (non-negative weights)
FloydWarshall AllPairs shortest path (handles negative weights)
Kruskal Minimum Spanning Tree
Prim Minimum Spanning Tree
SCC Strongly Connected Components

✅ References

  • Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein (CLRS)
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.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.7.4 29 8/27/2025
2.7.4-alpha 29 8/28/2025
2.7.3 29 8/27/2025
2.7.3-alpha 139 8/25/2025
2.7.2 81 8/15/2025
2.7.2-alpha.27 107 8/19/2025
2.7.2-alpha.26 113 8/18/2025
2.7.2-alpha.25 40 8/16/2025
2.7.2-alpha.24 52 8/15/2025
2.7.2-alpha.23 58 8/15/2025
2.7.2-alpha.22 66 8/15/2025
2.7.2-alpha.21 67 8/15/2025
2.7.2-alpha 107 8/21/2025
2.7.1-alpha.20 98 8/15/2025
2.7.1-alpha.19 118 8/14/2025
2.7.0-alpha.18 111 8/14/2025
2.7.0-alpha.17 114 8/14/2025
2.7.0-alpha.16 117 8/14/2025
2.6.2 132 8/13/2025
2.6.2-alpha.15 118 8/13/2025
2.6.1 126 8/11/2025
2.5.4 126 8/11/2025
2.5.3 197 8/7/2025
2.5.2 202 8/7/2025
2.5.1 201 8/7/2025
2.5.0 216 8/6/2025
2.4.1 217 8/6/2025