    .map(id => ({
        source: id,
        target: Math.round(Math.random() * (id-1))
      }));
    const gData = {
      nodes: [...Array(N).keys()].map(i => ({ id: i })),
      links
    };

    const Graph = new ForceGraph(document.getElementById('graph'))
      .linkDirectionalParticleColor(() => 'red')
      .linkHoverPrecision(10)
      .graphData(gData);

    Graph.onLinkClick(Graph.emitParticle); // emit particles on link click

    document.getElementById('emit-particles-btn').addEventListener(