summaryrefslogtreecommitdiff
path: root/app/data/randomdata.tsx
blob: 844f36fd2a91e15d02234a74292a31e359fe7b18 (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)),
      })),
  }
}