Interface IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic IDirectedGraph<TKey, TNodeValue, TEdgeValue> node.
public interface IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> where TKey : notnull
Type Parameters
TKey
Graph's key type.
TNodeValue
Graph node's value type.
TEdgeValue
Graph edge's value type.
- Extension Methods
Properties
Edges
Collection of IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instances connected to this node.
IReadOnlyCollection<IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>> Edges { get; }
Property Value
- IReadOnlyCollection<IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>>
Graph
Associated IReadOnlyDirectedGraph<TKey, TNodeValue, TEdgeValue> instance associated with this node.
IReadOnlyDirectedGraph<TKey, TNodeValue, TEdgeValue>? Graph { get; }
Property Value
- IReadOnlyDirectedGraph<TKey, TNodeValue, TEdgeValue>
Key
Underlying key.
TKey Key { get; }
Property Value
- TKey
Value
Underlying value.
TNodeValue Value { get; }
Property Value
- TNodeValue
Methods
ContainsEdgeTo(TKey)
Checks whether or not this node is connected with a node associated with the provided key
.
[Pure]
bool ContainsEdgeTo(TKey key)
Parameters
key
TKeyNode's key to check.
Returns
- bool
true when the two nodes are directly connected, otherwise false.
GetEdgeTo(TKey)
Returns an IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instance that connects this node
and the node associated with the provided key
.
[Pure]
IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> GetEdgeTo(TKey key)
Parameters
key
TKeyOther node's key.
Returns
- IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>
Exceptions
- KeyNotFoundException
When an edge to the node associated with the specified
key
does not exist.
GetReachableNodes(GraphDirection)
Creates a new IEnumerable<T> instance that contains all graph nodes that are reachable from this node,
using the provided direction
.
[Pure]
IEnumerable<IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>> GetReachableNodes(GraphDirection direction = GraphDirection.Out)
Parameters
direction
GraphDirectionDirection of node traversal. Equal to Out by default.
Returns
- IEnumerable<IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>>
New IEnumerable<T> instance.
TryGetEdgeTo(TKey, out IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>)
Attempts to return an IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instance that connects this node
and the node associated with the provided key
.
bool TryGetEdgeTo(TKey key, out IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> result)
Parameters
key
TKeyOther node's key.
result
IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>out parameter that returns an IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instance.
Returns
- bool
true when the connection exists, otherwise false.