Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ExtendedHierarchyNode<T, S, A>

Type parameters

  • T

  • S

  • A

Hierarchy

  • HierarchyNode<ProvenanceNode<S, A>>
    • ExtendedHierarchyNode

Index

Properties

Optional children

children: this[] | undefined

An array of child nodes, if any; undefined for leaf nodes.

column

column: number

data

data: ProvenanceNode<S, A>

The associated data, as specified to the constructor.

Readonly depth

depth: number

Zero for the root node, and increasing by one for each descendant generation.

Readonly height

height: number

Zero for leaf nodes, and the greatest distance from any descendant leaf for internal nodes.

Optional Readonly id

id: string | undefined

Optional node id string set by StratifyOperator, if hierarchical data was created from tabular data using stratify().

parent

parent: this | null

The parent node, or null for the root node.

Optional Readonly value

value: number | undefined

Aggregated numeric value as calculated by sum(value) or count(), if previously invoked.

Methods

ancestors

  • ancestors(): this[]
  • Returns the array of ancestors nodes, starting with this node, then followed by each parent up to the root.

    Returns this[]

copy

  • copy(): this
  • Return a deep copy of the subtree starting at this node. The returned deep copy shares the same data, however. The returned node is the root of a new tree; the returned node’s parent is always null and its depth is always zero.

    Returns this

count

  • count(): this
  • Computes the number of leaves under this node and assigns it to node.value, and similarly for every descendant of node. If this node is a leaf, its count is one. Returns this node.

    Returns this

descendants

  • descendants(): this[]
  • Returns the array of descendant nodes, starting with this node, then followed by each child in topological order.

    Returns this[]

each

  • each(func: (node: this) => void): this
  • Invokes the specified function for node and each descendant in breadth-first order, such that a given node is only visited if all nodes of lesser depth have already been visited, as well as all preceding nodes of the same depth.

    Parameters

    • func: (node: this) => void

      The specified function is passed the current node.

        • (node: this): void
        • Parameters

          • node: this

          Returns void

    Returns this

eachAfter

  • eachAfter(func: (node: this) => void): this
  • Invokes the specified function for node and each descendant in post-order traversal, such that a given node is only visited after all of its descendants have already been visited.

    Parameters

    • func: (node: this) => void

      The specified function is passed the current node.

        • (node: this): void
        • Parameters

          • node: this

          Returns void

    Returns this

eachBefore

  • eachBefore(func: (node: this) => void): this
  • Invokes the specified function for node and each descendant in pre-order traversal, such that a given node is only visited after all of its ancestors have already been visited.

    Parameters

    • func: (node: this) => void

      The specified function is passed the current node.

        • (node: this): void
        • Parameters

          • node: this

          Returns void

    Returns this

leaves

  • leaves(): this[]
  • Returns the array of leaf nodes in traversal order; leaves are nodes with no children.

    Returns this[]

links

  • links(): Array<HierarchyLink<ProvenanceNode<S, A>>>
  • Returns an array of links for this node, where each link is an object that defines source and target properties. The source of each link is the parent node, and the target is a child node.

    Returns Array<HierarchyLink<ProvenanceNode<S, A>>>

path

  • path(target: this): this[]
  • Returns the shortest path through the hierarchy from this node to the specified target node. The path starts at this node, ascends to the least common ancestor of this node and the target node, and then descends to the target node.

    Parameters

    • target: this

      The target node.

    Returns this[]

sort

  • sort(compare: (a: this, b: this) => number): this
  • Sorts the children of this node, if any, and each of this node’s descendants’ children, in pre-order traversal using the specified compare function, and returns this node.

    Parameters

    • compare: (a: this, b: this) => number

      The compare function is passed two nodes a and b to compare. If a should be before b, the function must return a value less than zero; if b should be before a, the function must return a value greater than zero; otherwise, the relative order of a and b are not specified. See array.sort for more.

        • (a: this, b: this): number
        • Parameters

          • a: this
          • b: this

          Returns number

    Returns this

sum

  • sum(value: (d: ProvenanceNode<S, A>) => number): this
  • Evaluates the specified value function for this node and each descendant in post-order traversal, and returns this node. The node.value property of each node is set to the numeric value returned by the specified function plus the combined value of all descendants.

    Parameters

    • value: (d: ProvenanceNode<S, A>) => number

      The value function is passed the node’s data, and must return a non-negative number.

        • (d: ProvenanceNode<S, A>): number
        • Parameters

          • d: ProvenanceNode<S, A>

          Returns number

    Returns this

Generated using TypeDoc