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

NameDescription
ChildrenGets the children of the node.
DataGets the data of the node.
DepthGets the number of ancestors of the node: 0 for the root.
HeightGets the length of the longest path from the node to a leaf: 0 for a leaf.
IsLeafGets a value that indicates whether the node has no children.
NameGets the name of the node, the default label of the charts.
ParentGets the parent of the node, or null for the root.
PathGets the names of the ancestors of the node and of the node, from the root, joined by /.
ValueGets the value of the node: its own value plus the values of its descendants, once HierarchyNode<T>.Sum or HierarchyNode<T>.Count is called.

Gets the children of the node.

public IReadOnlyList<HierarchyNode<T>> Children { get; }

Gets the data of the node.

public T Data { get; }

Property value

T

Gets the number of ancestors of the node: 0 for the root.

public int Depth { get; }

Property value

int

Gets the length of the longest path from the node to a leaf: 0 for a leaf.

public int Height { get; }

Property value

int

Gets a value that indicates whether the node has no children.

public bool IsLeaf { get; }

Property value

bool

Gets the name of the node, the default label of the charts.

public string Name { get; }

Property value

string

Gets the parent of the node, or null for the root.

public HierarchyNode<T>? Parent { get; }

Property value

HierarchyNode<T>?

Gets the names of the ancestors of the node and of the node, from the root, joined by /.

public string Path { get; }

Property value

string

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.

public double Value { get; }

Property value

double

Methods

NameDescription
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.

Returns the node and its ancestors, from the node to the root.

public IEnumerable<HierarchyNode<T>> Ancestors()

Sets 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.cs

Returns the node and its descendants, in pre-order: a node comes before its children.

public IEnumerable<HierarchyNode<T>> Descendants()

Returns the leaves under the node, in pre-order. The leaf of a leaf is itself.

public IEnumerable<HierarchyNode<T>> Leaves()

Sort(Comparison<HierarchyNode<T>>)

HierarchyNode`1.cs

Sorts the children of every node under this node.

public HierarchyNode<T> Sort(Comparison<HierarchyNode<T>> comparison)

Parameters

comparison Comparison<HierarchyNode<T>>
The comparison of two siblings.

Returns

HierarchyNode<T> The node, to chain calls.

SortByValue()

HierarchyNode`1.cs

Sorts 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.cs

Sets 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

value Func<T, double>
The own value of a node. NaN, infinite and negative values count as zero, and a sum larger than Double.MaxValue is Double.MaxValue.

Returns

HierarchyNode<T> The node, to chain calls.

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.