<h1>Force Graph Demo</h1>
<div id="graph"></div>
body {
  margin: 20px auto;
  font-family: 'Lato';
  font-weight: 300;
  overflow: hidden;
}

h1 {
  text-align: center;
}
// Random tree
const N = 30;
const gData = {
  nodes: [...Array(N).keys()].map((i) => ({ id: i })),
  links: [...Array(N).keys()]
    .filter((id) => id)
    .map((id) => ({
      source: id,
      target: Math.round(Math.random() * (id - 1))
    }))
};

const Graph = ForceGraph()(document.getElementById("graph"))
  .linkDirectionalParticles(2)
  .graphData(gData);

External CSS

  1. https://fonts.googleapis.com/css?family=Lato:300

External JavaScript

  1. https://unpkg.com/force-graph