MCPcopy Create free account
hub / github.com/breck7/scroll / treeRoot

Function treeRoot

external/.d3.js:13895–13916  ·  view source on GitHub ↗
(root)

Source from the content-addressed store, hash-verified

13893TreeNode.prototype = Object.create(Node$1.prototype);
13894
13895function treeRoot(root) {
13896 var tree = new TreeNode(root, 0),
13897 node,
13898 nodes = [tree],
13899 child,
13900 children,
13901 i,
13902 n;
13903
13904 while (node = nodes.pop()) {
13905 if (children = node._.children) {
13906 node.children = new Array(n = children.length);
13907 for (i = n - 1; i >= 0; --i) {
13908 nodes.push(child = node.children[i] = new TreeNode(children[i], i));
13909 child.parent = node;
13910 }
13911 }
13912 }
13913
13914 (tree.parent = new TreeNode(null, 0)).children = [tree];
13915 return tree;
13916}
13917
13918// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
13919function tree() {

Callers 1

treeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected