-
Notifications
You must be signed in to change notification settings - Fork 57
/
incremental.html
36 lines (32 loc) · 1.33 KB
/
incremental.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
32
33
34
35
36
<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 Graph = ForceGraph3D()(document.getElementById('3d-graph')).graphData({ nodes: [], links: []});
const session = driver.session({database:"gameofthrones"});
const start = new Date()
session
.run('MATCH (n) WITH n MATCH (n)-->(m) RETURN id(n) as source, id(m) as target LIMIT $limit', {limit: neo4j.int(5000)})
.then(function (result) {
result.records.forEach(r => {
const { nodes, links } = Graph.graphData();
const link={source:r.get('source').toNumber(), target:r.get('target').toNumber()}
Graph.graphData({
nodes: [...nodes, { id:link.source }, { id: link.target}],
links: [...links, link]
});
});
session.close();
console.log(Graph.graphData().links.length+" links loaded in "+(new Date()-start)+" ms.")
})
.catch(function (error) {
console.log(error);
});
</script>
</body>