MCPcopy Create free account
hub / github.com/microsoft/SandDance / treeRoot

Function treeRoot

docs/tests/v2/es6/js/sanddance.js:121922–121944  ·  view source on GitHub ↗
(root)

Source from the content-addressed store, hash-verified

121920TreeNode.prototype = Object.create(_index.Node.prototype);
121921
121922function treeRoot(root) {
121923 var tree = new TreeNode(root, 0),
121924 node,
121925 nodes = [tree],
121926 child,
121927 children,
121928 i,
121929 n;
121930
121931 while (node = nodes.pop()) {
121932 if (children = node._.children) {
121933 node.children = new Array(n = children.length);
121934
121935 for (i = n - 1; i >= 0; --i) {
121936 nodes.push(child = node.children[i] = new TreeNode(children[i], i));
121937 child.parent = node;
121938 }
121939 }
121940 }
121941
121942 (tree.parent = new TreeNode(null, 0)).children = [tree];
121943 return tree;
121944} // Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
121945
121946
121947function _default() {

Callers 1

treeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected