HierarchyNode<T> Class
A node of a tree, for the hierarchical charts (PackMark<T>, TreemapMark<T>, PartitionMark<T>). Create a tree with Hierarchy.
public sealed class HierarchyNode<T>Type parameters
T- The type of the data of the nodes.
Properties
| Name | Description |
|---|---|
| Children | Gets the children of the node. |
| Data | Gets the data of the node. |
| Depth | Gets the number of ancestors of the node: 0 for the root. |
| Height | Gets the length of the longest path from the node to a leaf: 0 for a leaf. |
| IsLeaf | Gets a value that indicates whether the node has no children. |
| Name | Gets the name of the node, the default label of the charts. |
| Parent | Gets the parent of the node, or null for the root. |
| Path | Gets the names of the ancestors of the node and of the node, from the root, joined by /. |
| Value | Gets the value of the node: its own value plus the values of its descendants, once HierarchyNode<T>.Sum or HierarchyNode<T>.Count is called. |
Children
HierarchyNode`1.csGets the children of the node.
public IReadOnlyList<HierarchyNode<T>> Children { get; }Property value
Gets the data of the node.
public T Data { get; }Property value
T
Depth
HierarchyNode`1.csHeight
HierarchyNode`1.csIsLeaf
HierarchyNode`1.csParent
HierarchyNode`1.csGets the parent of the node, or null for the root.
public HierarchyNode<T>? Parent { get; }Property value
Value
HierarchyNode`1.csGets the value of the node: its own value plus the values of its descendants, once HierarchyNode<T>.Sum or HierarchyNode<T>.Count is called.
public double Value { get; }Property value
Methods
| Name | Description |
|---|---|
| Ancestors() | Returns the node and its ancestors, from the node to the root. |
| Count() | Sets the value of every node under this node to its number of leaves (1 for a leaf). |
| Descendants() | Returns the node and its descendants, in pre-order: a node comes before its children. |
| Leaves() | Returns the leaves under the node, in pre-order. The leaf of a leaf is itself. |
| Sort(Comparison<HierarchyNode<T>>) | Sorts the children of every node under this node. |
| SortByValue() | Sorts the children of every node under this node by decreasing value, the usual order of treemaps and packed circles. |
| Sum(Func<T, double>) | Sets the value of every node under this node to its own value plus the values of its descendants. |
| ToString() | Returns a string that represents the current object. |
Ancestors()
HierarchyNode`1.csReturns the node and its ancestors, from the node to the root.
public IEnumerable<HierarchyNode<T>> Ancestors()Returns
IEnumerable<HierarchyNode<T>> The nodes.
Count()
HierarchyNode`1.csSets the value of every node under this node to its number of leaves (1 for a leaf).
public HierarchyNode<T> Count()Returns
HierarchyNode<T> The node, to chain calls.
Descendants()
HierarchyNode`1.csReturns the node and its descendants, in pre-order: a node comes before its children.
public IEnumerable<HierarchyNode<T>> Descendants()Returns
IEnumerable<HierarchyNode<T>> The nodes.
Leaves()
HierarchyNode`1.csReturns the leaves under the node, in pre-order. The leaf of a leaf is itself.
public IEnumerable<HierarchyNode<T>> Leaves()Returns
IEnumerable<HierarchyNode<T>> The leaves.
Sort(Comparison<HierarchyNode<T>>)
HierarchyNode`1.csSorts the children of every node under this node.
public HierarchyNode<T> Sort(Comparison<HierarchyNode<T>> comparison)Parameters
comparisonComparison<HierarchyNode<T>>- The comparison of two siblings.
Returns
HierarchyNode<T> The node, to chain calls.
SortByValue()
HierarchyNode`1.csSorts the children of every node under this node by decreasing value, the usual order of treemaps and packed circles.
public HierarchyNode<T> SortByValue()Returns
HierarchyNode<T> The node, to chain calls.
Sum(Func<T, double>)
HierarchyNode`1.csSets the value of every node under this node to its own value plus the values of its descendants.
public HierarchyNode<T> Sum(Func<T, double> value)Parameters
valueFunc<T, double>- The own value of a node. NaN, infinite and negative values count as zero, and a sum larger than
Double.MaxValueisDouble.MaxValue.
Returns
HierarchyNode<T> The node, to chain calls.