-
Notifications
You must be signed in to change notification settings - Fork 57
/
index.html
31 lines (28 loc) · 1.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/3d-force-graph"></script>
<script src="https://unpkg.com/neo4j-driver"></script>
<!--<script src="../../dist/3d-force-graph.js"></script>-->
</head>
<body>
<div id="3d-graph"></div>
<script>
const driver = neo4j.driver("bolt://demo.neo4jlabs.com", neo4j.auth.basic("gameofthrones", "gameofthrones"),{encrypted: true});
const session = driver.session({database:"gameofthrones"});
const start = new Date()
session
.run('MATCH (n)-[:INTERACTS1]->(m) RETURN id(n) as source, id(m) as target LIMIT $limit', {limit: neo4j.int(5000)})
.then(function (result) {
const links = result.records.map(r => { return {source:r.get('source').toNumber(), target:r.get('target').toNumber()}});
session.close();
console.log(links.length+" links loaded in "+(new Date()-start)+" ms.")
const ids = new Set()
links.forEach(l => {ids.add(l.source);ids.add(l.target);});
const gData = { nodes: Array.from(ids).map(id => {return {id}}), links: links}
const Graph = ForceGraph3D()(document.getElementById('3d-graph')).graphData(gData);
})
.catch(function (error) {
console.log(error);
});
</script>
</body>