Interface IGraph<T>
A graph data structure that stores nodes and edges.
Inherited Members
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public interface 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 to store in the graph. |
Properties
| Improve this Doc View SourceEdgeCount
The number of edges in the graph.
Declaration
int EdgeCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
NodeCount
The number of nodes in the graph.
Declaration
int NodeCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAdjacent(T, T)
Checks if an edge exists from a
to b
.
Declaration
bool Adjacent(T a, T b)
Parameters
Type | Name | Description |
---|---|---|
T | a | The start of the edge. |
T | b | The end of the edge. |
Returns
Type | Description |
---|---|
System.Boolean | True if an edge exists from |
EdgesBreak<TStep>(TStep)
Invokes a function on every edge in the graph.
Declaration
StepStatus EdgesBreak<TStep>(TStep step = default(TStep))
where TStep : struct, IFunc<(T, T), StepStatus>
Parameters
Type | Name | Description |
---|---|---|
TStep | step | The function to perform on every edge in the graph. |
Returns
Type | Description |
---|---|
StepStatus | The status of the traversal. |
Type Parameters
Name | Description |
---|---|
TStep | The type of the step function. |
GetNeighbours(T)
Gets enumerator of all neighbours of a node
Declaration
System.Collections.Generic.IEnumerable<T> GetNeighbours(T node)
Parameters
Type | Name | Description |
---|---|---|
T | node | The node to get neighbours of |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | IEnumerable of all neighbours of the given node |
Neighbors(T, Action<T>)
Gets all the nodes adjacent to a and performs the provided delegate on each.
Declaration
void Neighbors(T a, Action<T> function)
Parameters
Type | Name | Description |
---|---|---|
T | a | The node to find all the adjacent node to. |
Action<T> | function | The delegate to perform on each adjacent node to a. |
TryAdd(T, T)
Adds an edge to the graph starting at a and ending at b.
Declaration
(bool Success, Exception? Exception) TryAdd(T start, T end)
Parameters
Type | Name | Description |
---|---|---|
T | start | The stating point of the edge to add. |
T | end | The ending point of the edge to add. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> |
|
TryRemove(T, T)
Removes an edge from the graph.
Declaration
(bool Success, Exception? Exception) TryRemove(T start, T end)
Parameters
Type | Name | Description |
---|---|---|
T | start | The starting point of the edge to remove. |
T | end | The ending point of the edge to remove. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> |
|