Skip to content

Instantly share code, notes, and snippets.

@mariuz
Created June 4, 2012 18:04
Show Gist options
  • Save mariuz/2869910 to your computer and use it in GitHub Desktop.
Save mariuz/2869910 to your computer and use it in GitHub Desktop.
simple example with 3 nodes vivagraphjs test
<html>
<head>
<script src="./dist/vivagraph.js"></script>
<script type='text/javascript'>
function onLoad() {
var g = Viva.Graph.graph();
g.addNode('1','User name 1');
g.addNode('2','User name 2');
g.addNode('3','User name 3');
g.addLink('1', '2');
g.addLink('2', '3');
g.addLink('3', '1');
var renderer = Viva.Graph.View.renderer(g);
renderer.run();
//list each nodes from the graph
g.forEachNode(function(node){
console.log(node.id, node.data);
});
// show the connected nodes with user id 1
g.forEachLinkedNode('1', function(linkedNode, link){
console.log("Connected node: ", linkedNode.id, linkedNode.data);
console.dir(link); // link object itself
});
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
@keshy
Copy link

keshy commented Jul 31, 2017

this does not seem to be working on chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment