Created
June 9, 2016 14:54
-
-
Save jakab922/da8e49af76d6da6186ac856ca000ff82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Showing the relationship graph for question {{n}}</title> | |
<style> | |
#graph-container { | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
position: absolute; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="graph-container"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/1.1.0/sigma.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js"></script> | |
<script src="data/k03.js"></script> | |
<script> | |
var keys = Object.keys(gr); | |
var g = {nodes: [], edges: []}; | |
// Adding the nodes to the g object. | |
for(i = 0; i < keys.length; i++) { | |
var k = keys[i]; | |
g.nodes.push({ | |
id: k, | |
label: labels[k], | |
//size: gr[k].length, | |
color: '#666' | |
}); | |
} | |
// Adding the edges to the g object. | |
var eid = 0; | |
for(i = 0; i < keys.length; i++) { | |
var k = keys[i]; | |
var ki = parseInt(k); | |
for(j = 0; j < gr[k].length; j++) { | |
if(ki < gr[k][j]) { | |
g.edges.push({ | |
id: eid.toString(), | |
source: k, | |
target: gr[k][j].toString(), | |
color: '#ccc' | |
}); | |
eid += 1; | |
} | |
} | |
} | |
s = new sigma({ | |
graph: g, | |
container: "graph-container" | |
}); | |
console.log(g.nodes[0]); | |
console.log(g.edges[0]); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment