Skip to content

Instantly share code, notes, and snippets.

@kedar9444
Last active October 2, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kedar9444/4e1813aa0f2e73508cbfe9d18e3d0f6e to your computer and use it in GitHub Desktop.
Save kedar9444/4e1813aa0f2e73508cbfe9d18e3d0f6e to your computer and use it in GitHub Desktop.
var R = require("ramda");
var randrange = require("random-number-in-range");
var count = 100;
var nodes = R.range(0, 100).map((_, x) => ({ "name": x, "group": Math.floor(x * 7 / count) }));
var links = R.range(0, Math.floor(count * 1.15)).map(function(_, x)
{
var source = x % count;
var target = Math.floor(Math.log(1 + randrange(0, count)) / Math.log(1.3));
var value = 10.0 / (1 + Math.abs(source - target));
return { "source": source, "target": target, "value": value };
})
var d3Graph = require("@runkit/runkit/d3-graph/1.0.0");
d3Graph(nodes, links)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment