blob: 21624851a747e1bba8af5991760321e15a7b1cf0 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
function genRandomTree(N = 300, reverse = false) {
return {
nodes: [...Array(N).keys()].map((i) => ({ id: i })),
links: [...Array(N).keys()]
.filter((id) => id)
.map((id) => ({
[reverse ? 'target' : 'source']: id,
[reverse ? 'source' : 'target']: Math.round(Math.random() * (id - 1)),
})),
}
}
|