Skip to content

Instantly share code, notes, and snippets.

@brianrusso
Created June 7, 2016 01:37
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 brianrusso/5439c7b716d548ad138e3d21cfb4c5e7 to your computer and use it in GitHub Desktop.
Save brianrusso/5439c7b716d548ad138e3d21cfb4c5e7 to your computer and use it in GitHub Desktop.
{"directed": false, "graph": {}, "nodes": [{"id": 716800}, {"id": 1017728}, {"id": 22275}, {"id": 592388}, {"id": 120709}, {"id": 498694}, {"id": 25099}, {"id": 1155212}, {"id": 677774}, {"id": 321039}, {"id": 121248}, {"id": 358806}, {"id": 196759}, {"id": 151576}, {"id": 1691674}, {"id": 385563}, {"id": 223901}, {"id": 379550}, {"id": 27717}, {"id": 583200}, {"id": 99708}, {"id": 555043}, {"id": 649253}, {"id": 55720}, {"id": 1152297}, {"id": 479794}, {"id": 1666738}, {"id": 950150}, {"id": 1390265}, {"id": 807866}, {"id": 1484732}, {"id": 580029}, {"id": 119614}, {"id": 470816}, {"id": 1438145}, {"id": 304324}, {"id": 1329477}, {"id": 411336}, {"id": 1603212}, {"id": 1280202}, {"id": 239820}, {"id": 114381}, {"id": 1627345}, {"id": 407843}, {"id": 1181785}, {"id": 516442}, {"id": 305115}, {"id": 36828}, {"id": 1264634}, {"id": 1239936}, {"id": 1051235}, {"id": 1175656}, {"id": 1574249}, {"id": 1266027}, {"id": 468845}, {"id": 1225149}, {"id": 943400}, {"id": 1421824}, {"id": 1690612}, {"id": 1669467}, {"id": 490111}, {"id": 902799}, {"id": 343039}], "links": [{"source": 0, "target": 29}, {"source": 1, "target": 29}, {"source": 2, "target": 29}, {"source": 3, "target": 29}, {"source": 4, "target": 29}, {"source": 5, "target": 29}, {"source": 6, "target": 29}, {"source": 7, "target": 29}, {"source": 8, "target": 29}, {"source": 9, "target": 29}, {"source": 10, "target": 29}, {"source": 11, "target": 29}, {"source": 12, "target": 29}, {"source": 13, "target": 29}, {"source": 14, "target": 29}, {"source": 15, "target": 29}, {"source": 16, "target": 29}, {"source": 17, "target": 29}, {"source": 18, "target": 29}, {"source": 19, "target": 29}, {"source": 20, "target": 29}, {"source": 21, "target": 29}, {"source": 22, "target": 29}, {"source": 23, "target": 29}, {"source": 24, "target": 29}, {"source": 25, "target": 29}, {"source": 26, "target": 29}, {"source": 27, "target": 29}, {"source": 28, "target": 29}, {"source": 29, "target": 30}, {"source": 29, "target": 31}, {"source": 29, "target": 32}, {"source": 29, "target": 33}, {"source": 29, "target": 34}, {"source": 29, "target": 35}, {"source": 29, "target": 36}, {"source": 29, "target": 37}, {"source": 29, "target": 38}, {"source": 29, "target": 39}, {"source": 29, "target": 40}, {"source": 29, "target": 41}, {"source": 29, "target": 42}, {"source": 29, "target": 43}, {"source": 29, "target": 44}, {"source": 29, "target": 45}, {"source": 29, "target": 46}, {"source": 29, "target": 47}, {"source": 29, "target": 48}, {"source": 29, "target": 49}, {"source": 29, "target": 50}, {"source": 29, "target": 51}, {"source": 29, "target": 52}, {"source": 29, "target": 53}, {"source": 29, "target": 54}, {"source": 29, "target": 55}, {"source": 29, "target": 56}, {"source": 29, "target": 57}, {"source": 29, "target": 58}, {"source": 29, "target": 59}, {"source": 29, "target": 60}, {"source": 29, "target": 61}, {"source": 29, "target": 62}], "multigraph": false}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
stroke: #999;
stroke-opacity: .6;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 500;
var color = d3.scale.category20();
var force = d3.layout.force()
.charge(-120)
.linkDistance(30)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("aminer_subgraph1.json", function(error, graph) {
if (error) throw error;
force
.nodes(graph.nodes)
.links(graph.links)
.start();
var link = svg.selectAll(".link")
.data(graph.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return Math.sqrt(d.value); });
var node = svg.selectAll(".node")
.data(graph.nodes)
.enter().append("circle")
.attr("class", "node")
.attr("r", 5)
.style("fill", function(d) { return color(d.group); })
.call(force.drag);
node.append("title")
.text(function(d) { return d.name; });
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment