summaryrefslogtreecommitdiff
path: root/app/data/randomdata.js
blob: 55e5598eb93aa18a7afa390780ee592d80389ac1 (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))
    }))
  };
}