SharpGraph 1.3.2
See the version list below for details.
dotnet add package SharpGraph --version 1.3.2
NuGet\Install-Package SharpGraph -Version 1.3.2
<PackageReference Include="SharpGraph" Version="1.3.2" />
<PackageVersion Include="SharpGraph" Version="1.3.2" />
<PackageReference Include="SharpGraph" />
paket add SharpGraph --version 1.3.2
#r "nuget: SharpGraph, 1.3.2"
#:package SharpGraph@1.3.2
#addin nuget:?package=SharpGraph&version=1.3.2
#tool nuget:?package=SharpGraph&version=1.3.2
SharpGraph

A C# graph library with support for both directed- and undirected graphs (simpel- and multigraphs).
Features
- Serializable to json and deserializable from json.
- Graph properties:
- Vertices
- Edges (arrows and lines)
- Sources
- Sinks
- IsAcyclic
- HasCycles
- Density
- IsSparse
- IsDense
- IsDirected
- IsDirectedAcyclic
- Graph methods:
- AddVertex (given a vertex)
- AddEdge (given a edge)
- AdjacentVertices (given a vertex)
- AdjacentEdges (given a vertex)
- AllPaths (between two given vertices)
- Multiple graph representations available.
- AdjacencyList
- AdjacencyMatrix
Nuget
Install-Package SharpGraph
How to use
Step 1
Create a vertex class by extending the Vertex base class.
public class TestVertex : Vertex
{
public TestVertex(string identifier)
: base(identifier)
{
}
}
Step 2
Create a edge class by extending either the Line class (undirected edge) or the Arrow class (directed edge).
public class TestArrow : Arrow<TestVertex>
{
public TestArrow(TestVertex source, TestVertex target)
: base(source, target)
{
}
}
Step 3
Create a new instance of the Graph class with your own vertex and edge classes as generic types. You can use a fluent syntax for adding vertices and edges.
var vertex1 = new TestVertex("A");
var vertex2 = new TestVertex("B");
var vertex3 = new TestVertex("C");
var vertex4 = new TestVertex("D");
var graph = new Graph<TestVertex, TestArrow>()
.AddVertex(vertex1)
.AddVertex(vertex2)
.AddVertex(vertex3)
.AddVertex(vertex4)
.AddEdge(new TestArrow(vertex1, vertex2))
.AddEdge(new TestArrow(vertex1, vertex3))
.AddEdge(new TestArrow(vertex2, vertex4))
.AddEdge(new TestArrow(vertex3, vertex4));
var pathsVertex1ToVertex4 = graph.AllPaths(vertex1, vertex4);
foreach (var path in pathsVertex1ToVertex4)
{
Console.WriteLine(string.Join(", ", path.Select(i => $"{i.Source}->{i.Target}")));
}
This gives the following result on the console.
A->B, B->D
A->C, C->D
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- morelinq (>= 4.3.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpGraph:
| Package | Downloads |
|---|---|
|
SharpMachineLearning
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.7.1 | 128 | 2/3/2026 |
| 1.7.0 | 88 | 2/3/2026 |
| 1.6.9 | 122 | 1/10/2026 |
| 1.6.8 | 110 | 1/6/2026 |
| 1.6.7 | 104 | 1/4/2026 |
| 1.6.6 | 116 | 1/2/2026 |
| 1.6.5 | 108 | 1/2/2026 |
| 1.6.4 | 111 | 1/1/2026 |
| 1.6.3 | 107 | 1/1/2026 |
| 1.6.2 | 103 | 1/1/2026 |
| 1.6.1 | 106 | 1/1/2026 |
| 1.6.0 | 106 | 1/1/2026 |
| 1.5.8 | 115 | 1/1/2026 |
| 1.5.7 | 216 | 12/22/2025 |
| 1.5.6 | 203 | 12/22/2025 |
| 1.5.5 | 191 | 12/21/2025 |
| 1.5.4 | 185 | 12/21/2025 |
| 1.5.3 | 186 | 12/21/2025 |
| 1.5.2 | 177 | 12/21/2025 |
| 1.3.2 | 239 | 9/1/2024 |