Interface IGraphWeighted<T, TWeight>
A weighted graph data structure that stores nodes, edges with their corresponding weights.
Inherited Members
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public interface IGraphWeighted<T, TWeight> : IGraph<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.IAddable<T>, DataStructure.IRemovable<T>, DataStructure.IClearable
Type Parameters
Name | Description |
---|---|
T | The generic node type of this graph. |
TWeight | The generic weight type of this graph. |
Methods
| Improve this Doc View SourceAdjacent(T, T, out TWeight)
Checks if b is adjacent to a.
Declaration
bool Adjacent(T a, T b, out TWeight weight)
Parameters
Type | Name | Description |
---|---|---|
T | a | The starting point of the edge to check. |
T | b | The ending point of the edge to check. |
TWeight | weight | The weight of the edge, if it exists. |
Returns
Type | Description |
---|---|
System.Boolean | True if b is adjacent to a; False if not |
EdgesAndWeightsToArray()
Enumerates and returns all edges present in the graph
Declaration
(T, T, TWeight)[] EdgesAndWeightsToArray()
Returns
Type | Description |
---|---|
System.ValueTuple<T, T, TWeight>[] | Array of Tuple of nodes and weight that represent an edge |
EdgesToArray()
Enumerates and returns all edges present in the graph
Declaration
(T, T)[] EdgesToArray()
Returns
Type | Description |
---|---|
System.ValueTuple<T, T>[] | Array of Tuple of nodes that represent an edge |
GetWeight(T, T)
Gets the weight of an edge.
Declaration
TWeight GetWeight(T a, T b)
Parameters
Type | Name | Description |
---|---|---|
T | a | The starting node of the edge. |
T | b | The ending node of the edge. |
Returns
Type | Description |
---|---|
TWeight | The weight of the edge. |
TryAdd(T, T, TWeight)
Adds a weighted edge to the graph
Declaration
(bool Success, Exception? Exception) TryAdd(T start, T end, TWeight weight)
Parameters
Type | Name | Description |
---|---|---|
T | start | The starting point of the edge to add |
T | end | The ending point of the edge to add |
TWeight | weight | The weight of the edge |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | (
|
Explicit Interface Implementations
| Improve this Doc View SourceIGraph<T>.TryAdd(T, T)
Declaration
(bool Success, Exception? Exception) IGraph<T>.TryAdd(T start, T end)
Parameters
Type | Name | Description |
---|---|---|
T | start | |
T | end |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> |