Interface IReadOnlyDirectedGraph<TKey, TNodeValue, TEdgeValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic read-only directed graph data structure.
public interface IReadOnlyDirectedGraph<TKey, TNodeValue, TEdgeValue> where TKey : notnull
Type Parameters
TKeyKey type.
TNodeValueNode's value type.
TEdgeValueNode's edge type.
Properties
Edges
Specifies the current collection of IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instances that belong to this graph.
IEnumerable<IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>> Edges { get; }
Property Value
- IEnumerable<IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>>
KeyComparer
Key equality comparer.
IEqualityComparer<TKey> KeyComparer { get; }
Property Value
- IEqualityComparer<TKey>
Nodes
Specifies the current collection of IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> instances that belong to this graph.
IReadOnlyCollection<IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>> Nodes { get; }
Property Value
- IReadOnlyCollection<IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>>
Methods
Contains(IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>)
Checks whether or not the provided edge exists in this graph.
[Pure]
bool Contains(IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> edge)
Parameters
edgeIDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>Edge to check.
Returns
- bool
true when edge exists, otherwise false.
Contains(IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>)
Checks whether or not the provided node exists in this graph.
[Pure]
bool Contains(IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> node)
Parameters
nodeIDirectedGraphNode<TKey, TNodeValue, TEdgeValue>Node to check.
Returns
- bool
true when node exists, otherwise false.
ContainsEdge(TKey, TKey)
Checks whether or not an edge that connects nodes associated with the firstKey and secondKey
exists in this graph.
[Pure]
bool ContainsEdge(TKey firstKey, TKey secondKey)
Parameters
firstKeyTKeyKey of the first node to check.
secondKeyTKeyKey of the second node to check.
Returns
- bool
true when edge exists, otherwise false.
ContainsNode(TKey)
Checks whether or not a node with the specified key exists in this graph.
[Pure]
bool ContainsNode(TKey key)
Parameters
keyTKeyKey to check.
Returns
- bool
true when node exists, otherwise false.
GetEdge(TKey, TKey)
Returns the edge that connects nodes associated with the specified firstKey and secondKey.
[Pure]
IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> GetEdge(TKey firstKey, TKey secondKey)
Parameters
firstKeyTKeyFirst node's key.
secondKeyTKeySecond node's key.
Returns
- IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>
IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instance that connects nodes associated with
firstKeyandsecondKey.
Exceptions
- KeyNotFoundException
When
firstKeydoes not exist in this graph or when an edge from the first node to the node associated with the specifiedsecondKeydoes not exist.
GetNode(TKey)
Returns the node associated with the specified key.
[Pure]
IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> GetNode(TKey key)
Parameters
keyTKeyNode's key.
Returns
- IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>
IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> instance associated with the provided
key.
Exceptions
- KeyNotFoundException
When key does not exist in this graph.
TryGetEdge(TKey, TKey, out IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>)
Returns the edge that connects nodes associated with the specified firstKey and secondKey.
[Pure]
bool TryGetEdge(TKey firstKey, TKey secondKey, out IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> result)
Parameters
firstKeyTKeyFirst node's key.
secondKeyTKeySecond node's key.
resultIDirectedGraphEdge<TKey, TNodeValue, TEdgeValue>out parameter that returns an IDirectedGraphEdge<TKey, TNodeValue, TEdgeValue> instance that connects nodes associated with
firstKeyandsecondKey.
Returns
- bool
true when the edge exists, otherwise false.
TryGetNode(TKey, out IDirectedGraphNode<TKey, TNodeValue, TEdgeValue>)
Attempts to return the node associated with the specified key.
bool TryGetNode(TKey key, out IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> result)
Parameters
keyTKeyNode's key.
resultIDirectedGraphNode<TKey, TNodeValue, TEdgeValue>out parameter that returns an IDirectedGraphNode<TKey, TNodeValue, TEdgeValue> instance associated with the provided
key.
Returns
- bool
true when the node exists, otherwise false.