Class GraphSetOmnitree<T, TEquate, THash>
Stores the graph as a set-hash of nodes and quadtree of edges.
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class GraphSetOmnitree<T, TEquate, THash> : object, IGraph<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.IAddable<T>, DataStructure.IRemovable<T>, DataStructure.IClearable, ICloneable<GraphSetOmnitree<T, TEquate, THash>>, DataStructure.IEquating<T, TEquate>, DataStructure.IHashing<T, THash> where TEquate : struct, IFunc<T, T, bool> where THash : struct, IFunc<T, int>
Type Parameters
Name | Description |
---|---|
T | The generic type of this data structure. |
TEquate | The type of function for quality checking |
THash | The type of function for hashing |
Constructors
| Improve this Doc View SourceGraphSetOmnitree(TEquate, THash, Nullable<Func<T, T, CompareResult>>)
Constructs a new GraphSetOmnitree.
Declaration
public GraphSetOmnitree(TEquate equate = default(TEquate), THash hash = default(THash), Func<T, T, CompareResult>? compare = null)
Parameters
Type | Name | Description |
---|---|---|
TEquate | equate | The equate delegate for the data structure to use. |
THash | hash | The hash delegate for the datastructure to use. |
System.Nullable<Func<T, T, CompareResult>> | compare | The compare delegate for the data structure to use. |
Properties
| Improve this Doc View SourceEdgeCount
The number of edges in the graph.
Declaration
public int EdgeCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Equate
Gets the value of the type that is checking T
values for equality.
Declaration
public TEquate Equate { get; }
Property Value
Type | Description |
---|---|
TEquate |
Hash
Gets the value of the type that is hashing T
values.
Declaration
public THash Hash { get; }
Property Value
Type | Description |
---|---|
THash |
NodeCount
The number of nodes in the graph.
Declaration
public 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
public 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 |
Clear()
Returns the data structure to an empty state.
Declaration
public void Clear()
Clone()
Clones a T
.
Declaration
public GraphSetOmnitree<T, TEquate, THash> Clone()
Returns
Type | Description |
---|---|
GraphSetOmnitree<T, TEquate, THash> | A clone of the |
EdgesBreak<TStep>(TStep)
Invokes a function on every edge in the graph.
Declaration
public 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. |
GetEnumerator()
Declaration
public System.Collections.Generic.IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
GetNeighbours(T)
Gets enumerator of all neighbours of a node
Declaration
public 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
public void Neighbors(T node, Action<T> step)
Parameters
Type | Name | Description |
---|---|---|
T | node | |
Action<T> | step |
StepperBreak<TStep>(TStep)
Traverses values and invokes a function on every T
value.
Declaration
public StepStatus StepperBreak<TStep>(TStep step = default(TStep))
where TStep : struct, IFunc<T, StepStatus>
Parameters
Type | Name | Description |
---|---|---|
TStep | step | The function to invoke on every |
Returns
Type | Description |
---|---|
StepStatus | The status of the traversal. |
Type Parameters
Name | Description |
---|---|
TStep | The type of function to invoke on every |
ToArray()
Constructs an array with the values of this data structure.
Declaration
public T[] ToArray()
Returns
Type | Description |
---|---|
T[] | An array with the values of this data structure. |
TryAdd(T)
Tries to add a value to a data structure.
Declaration
public (bool Success, Exception? Exception) TryAdd(T node)
Parameters
Type | Name | Description |
---|---|---|
T | node |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was added or false if not. |
TryAdd(T, T)
Adds an edge to the graph starting at a and ending at b.
Declaration
public (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)
Tries to remove a value.
Declaration
public (bool Success, Exception? Exception) TryRemove(T node)
Parameters
Type | Name | Description |
---|---|---|
T | node |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was removed or false if not. |
TryRemove(T, T)
Removes an edge from the graph.
Declaration
public (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>> |
|