Show / Hide Table of Contents

Interface IGraph<T>

A graph data structure that stores nodes and edges.

Inherited Members
IDataStructure<T>.ToArray()
ISteppable<T>.StepperBreak<TStep>(TStep)
DataStructure.IAddable<T>.TryAdd(T)
DataStructure.IRemovable<T>.TryRemove(T)
DataStructure.IClearable.Clear()
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 Source

EdgeCount

The number of edges in the graph.

Declaration
int EdgeCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NodeCount

The number of nodes in the graph.

Declaration
int NodeCount { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

Adjacent(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 a to b; False if not

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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>>
  • Success: true if the edge was added or false if not
  • ? Exception: the exception that occured if the add failed
| Improve this Doc View Source

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>>
  • Success: true if the edge was removed or false if not
  • ? Exception: the exception that occured if the remove failed

Extension Methods

Steppable.Stepper<T>(ISteppable<T>, Action<T>)
Steppable.Stepper<T, TStep>(ISteppable<T>, TStep)
Steppable.StepperBreak<T>(ISteppable<T>, Func<T, StepStatus>)
DataStructure.Add<T>(DataStructure.IAddable<T>, T)
DataStructure.Remove<T>(DataStructure.IRemovable<T>, T)
Graph.Add<T>(IGraph<T>, T, T)
Graph.Remove<T>(IGraph<T>, T)
Graph.Remove<T>(IGraph<T>, T, T)
Graph.Edges<T>(IGraph<T>, Action<(T, T)>)
Graph.Edges<T, TStep>(IGraph<T>, TStep)
Graph.EdgesBreak<T>(IGraph<T>, Func<(T, T), StepStatus>)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX