UNPKG

phylojs

Version:

A simple typescript library for phylogenetic trees

76 lines (75 loc) 2.3 kB
export declare class Node { /** Node id */ id: number; /** Node parent */ parent: Node | undefined; /** descending nodes */ children: Node[]; /** Heigh above the root */ height: number | undefined; /** Root to tip distance for each tip */ rttDist: number | undefined; /** Length of descending branch */ branchLength: number | undefined; /** Node label */ label: string | undefined; /** Node annotation(s) */ annotation: { [key: string]: any; }; /** ID of node if hybrid */ hybridID: number | undefined; /** * The constructor of the `Node` class. * * @param {number} id node `id` number */ constructor(id: number); /** Ensure nodes with unique IDs have unique hashes. */ toString(): string; /** * Appends child node to `children` * @param {Node} child */ addChild(child: Node): void; /** * Removes a node from `children` * @param {Node} child */ removeChild(child: Node): void; /** Checks if a node is root */ isRoot(): boolean; /** Check if a node is a Leaf */ isLeaf(): boolean; /** Checks if node only has one child */ isSingleton(): boolean; /** Checks if a node is a hybrid node */ isHybrid(): boolean; /** * Gets ancestral nodes * @param {Node} node */ private _getAncestors; /** Gets ancestral nodes. Wraps `_getAncestors` to handle concat types. */ getAncestors(): Node[]; /** * Returns true if this node is left of the argument on the * tree. If one node is the direct ancestor of the other, * the result is undefined. * * @param {Node} other * */ isLeftOf(other: Node): boolean | undefined; /** Produce a deep copy of the clade below this node */ copy(): Node; /** * Apply a function `f()` to each node in a subtree descending from `node` in pre-order * @param {Node} node Node from which to apply `f()` pre-order */ applyPreOrder<T>(f: (node: Node) => T): T[]; /** * Apply a function `f()` to each node in a subtree descending from `node` in post-order * @param {Node} node Node from which to apply `f()` post-order */ applyPostOrder<T>(f: (node: Node) => T): T[]; }