Public
Edited
Apr 6, 2023
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tree = {
new_tree;
let p = 0.7;
let root = { depth: 0, children: [], blah: 0 };
let cnt = 1;
let max_depth = 0;
let stack = [root];

while (stack.length > 0 && cnt < 10000) {
let node = stack.pop();
let depth = node.depth;
for (let i = 0; i < 3; i++) {
if (d3.randomUniform(0, 1)() < p ** node.depth) {
cnt = cnt + 1;
let child = { depth: node.depth + 1, children: [] };
node.children.push(child);
stack.push(child);
if (child.depth > max_depth) {
max_depth = child.depth;
}
}
}
}
return root;
}
Insert cell
size_break = 600
Insert cell
margin = 10
Insert cell
h = 0.625 * w;
Insert cell
w = d3.min([width, 1000])
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more