Class TreeNodeBase
Provides a base contract for nodes that will be used in a tree.
public abstract class TreeNodeBase : INode
- Inheritance
-
TreeNodeBase
- Implements
- Inherited Members
Properties
InDegree
Gets a value indicating the number of incoming edges that this node is incident to.
public int InDegree { get; }
Property Value
OutDegree
Gets a value indicating the number of outgoing edges that this node is incident to.
public int OutDegree { get; }
Property Value
Parent
The parent of this TreeNodeBase
public TreeNodeBase? Parent { get; }
Property Value
Methods
GetChildren()
Gets the children of the current TreeNodeBase.
public abstract IEnumerable<TreeNodeBase> GetChildren()
Returns
- IEnumerable<TreeNodeBase>
The children.
GetIncomingEdges()
Gets a collection of all edges that target this node.
public IEnumerable<IEdge> GetIncomingEdges()
Returns
- IEnumerable<IEdge>
The incoming edges.
GetOutgoingEdges()
Gets a collection of all outgoing edges originating from this node.
public IEnumerable<IEdge> GetOutgoingEdges()
Returns
- IEnumerable<IEdge>
The outgoing edges.
GetPredecessors()
Gets a collection of nodes that precede this node.
public IEnumerable<INode> GetPredecessors()
Returns
- IEnumerable<INode>
The predecessor nodes.
GetSuccessors()
Gets a collection of nodes that can be reached from this node by following one of the incident edges.
public IEnumerable<INode> GetSuccessors()
Returns
- IEnumerable<INode>
The successor nodes.
HasPredecessor(INode)
Determines whether the provided node precedes the current node.
public bool HasPredecessor(INode node)
Parameters
nodeINodeThe node to check.
Returns
- bool
Trueif the node is a predecessor,falseotherwise.
HasSuccessor(INode)
Determines whether the provided node can be reached from this node by following one of the incident edges.
public bool HasSuccessor(INode node)
Parameters
nodeINodeThe node to check.
Returns
- bool
Trueif the node is a successor,falseotherwise.
OnParentChanged(TreeNodeBase?)
Called when the parent of the tree node changes.
protected virtual void OnParentChanged(TreeNodeBase? old)
Parameters
oldTreeNodeBaseThe original tree node parent.
UpdateChildNotNull<T>(ref T, T)
Updates the value and the parent of the child node, ensuring that the new value is not
null.
protected void UpdateChildNotNull<T>(ref T child, T value) where T : TreeNodeBase
Parameters
childTThe child element to update.
valueTThe new value to assign to the
child.
Type Parameters
T
Exceptions
- ArgumentNullException
When the new node is
null.- InvalidOperationException
When the node already has a parent.
UpdateChild<T>(ref T?, T?)
Updates the value and the parent of the child node.
protected void UpdateChild<T>(ref T? child, T? value) where T : TreeNodeBase
Parameters
childTThe child element to update.
valueTThe new value to assign to the
child.
Type Parameters
T
Exceptions
- InvalidOperationException
When the node already has a parent.