node.sort()

node.sort(compare) 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. The specified 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. Unlike

node.links()

node.links() 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.

node.path()

node.path(target) 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. This is particularly useful for hierarchical edge bundling.

node.eachBefore()

node.eachBefore(function) 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. The specified function is passed the current node.

node.leaves()

node.leaves() Returns the array of leaf nodes in traversal order; leaves are nodes with no children.

node.eachAfter()

node.eachAfter(function) 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. The specified function is passed the current node.

node.copy()

node.copy() 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.

node.each()

node.each(function) 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 preceeding nodes of the same depth. The specified function is passed the current node.

node.ancestors()

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

node.descendants()

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