Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var can = document.getElementById("can");
- var myCanvas = new Canvas(can);
- var myGraph = new Graph(myCanvas);
- var nodes = [];
- var edges = [];
- function addTree(data, parent) {
- var node = new Node("node" + data.id, 300);
- nodes.push(node);
- if (parent != null) {
- edges.push(new Edge(node, parent));
- }
- for (i in data.children) {
- addTree(data.children[i], node)
- }
- }
- $.getJSON('/words/1.json', function(data) {
- addTree(data, null);
- for (n in nodes) {
- myGraph.addNode(nodes[n]);
- }
- for (e in edges) {
- myGraph.addEdge(edges[e]);
- }
- });
Add Comment
Please, Sign In to add comment