Table of Contents

Class GraphMinimumSpanningTreeExtensions

Namespace
Graph1x.Algorithms
Assembly
Graph1x.dll

Convenience entry points for minimum-spanning-forest queries. These default to Kruskal; instantiate PrimMinimumSpanningTree<TVertex, TEdge, TWeight> directly to use Prim.

public static class GraphMinimumSpanningTreeExtensions
Inheritance
GraphMinimumSpanningTreeExtensions
Inherited Members

Methods

MinimumSpanningForest<TVertex, TWeight>(IReadOnlyGraph<TVertex, WeightedEdge<TVertex, TWeight>>)

Computes a minimum spanning forest using Kruskal's algorithm and the weights carried by the graph's WeightedEdge<TVertex, TWeight> edges.

public static IReadOnlyList<WeightedEdge<TVertex, TWeight>> MinimumSpanningForest<TVertex, TWeight>(this IReadOnlyGraph<TVertex, WeightedEdge<TVertex, TWeight>> graph) where TVertex : notnull where TWeight : INumber<TWeight>

Parameters

graph IReadOnlyGraph<TVertex, WeightedEdge<TVertex, TWeight>>

The undirected graph to span.

Returns

IReadOnlyList<WeightedEdge<TVertex, TWeight>>

The chosen edges.

Type Parameters

TVertex

The vertex type.

TWeight

The numeric weight type.

Exceptions

ArgumentException

graph is directed.

MinimumSpanningForest<TVertex, TEdge, TWeight>(IReadOnlyGraph<TVertex, TEdge>, Func<TEdge, TWeight>)

Computes a minimum spanning forest using Kruskal's algorithm and weightSelector to read edge weights.

public static IReadOnlyList<TEdge> MinimumSpanningForest<TVertex, TEdge, TWeight>(this IReadOnlyGraph<TVertex, TEdge> graph, Func<TEdge, TWeight> weightSelector) where TVertex : notnull where TEdge : IEdge<TVertex> where TWeight : INumber<TWeight>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The undirected graph to span.

weightSelector Func<TEdge, TWeight>

Maps an edge to its weight.

Returns

IReadOnlyList<TEdge>

The chosen edges.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

TWeight

The numeric weight type.

Exceptions

ArgumentException

graph is directed.