blob: f24a2ba5800d3eafcbd253923199ae736ebf649c (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
export default 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))
}))
};
}
|