Arborescence is a generic .NET library for dealing with graphs.
- Abstractions — interfaces and concepts for examining graphs and collections in a data-structure-agnostic way.
- Models — generic graph structures that implement the aforementioned interfaces.
- Models.Specialized — special adjacency and incidence graph data structures that provide efficient implementation when vertices are integers from contiguous range.
- Primitives — building blocks for creating various data structures and APIs.
- Primitives.Specialized — efficient specializations for different vocabulary generic types.
- Traversal — widely used graph traversal algorithms such as BFS and DFS.
- Traversal.Specialized — traversal algorithms specialized for integer vertices from a contiguous range.
To install packages of this library using the NuGet package manager, follow the links above.
Let's consider a simple directed graph and a breadth-first tree on it:
This is how you create a graph and run an algorithm against the graph:
using Traversal.Adjacency;
...
Endpoints<int>[] edges =
{
new(2, 0),
new(4, 3),
new(0, 4),
new(3, 2),
new(4, 4),
new(0, 2),
new(2, 4)
};
var graph = Int32AdjacencyGraph.FromEdges(edges);
IEnumerable<Endpoints<int>> treeEdges =
EnumerableBfs<int, ArraySegment<int>.Enumerator>.EnumerateEdges(
graph, source: 3);
foreach (Endpoints<int> edge in treeEdges)
Console.WriteLine(edge);
Expected output:
[3, 2]
[2, 0]
[2, 4]
For more sophisticated examples examine samples/ directory.
The icon is designed by OpenMoji — the open-source emoji and icon project. License: CC BY-SA 4.0.