Created
March 29, 2018 19:26
-
-
Save jexp/ebcf16bc607bb62b458e3e8b10c26e1c to your computer and use it in GitHub Desktop.
Neo4j Demo for https://github.com/vasturiano/3d-force-graph
This file contains 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
<head> | |
<style> body { margin: 0; } </style> | |
<script src="//unpkg.com/3d-force-graph"></script> | |
<script src="//cdn.rawgit.com/neo4j/neo4j-javascript-driver/1.2/lib/browser/neo4j-web.min.js"></script> | |
<!--<script src="../../dist/3d-force-graph.js"></script>--> | |
</head> | |
<body> | |
<div id="3d-graph"></div> | |
<script> | |
const driver = neo4j.v1.driver("bolt://localhost", neo4j.v1.auth.basic("neo4j", "test")); | |
const session = driver.session(); | |
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: 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:id}}), links: links} | |
const Graph = ForceGraph3D()(document.getElementById('3d-graph')).graphData(gData); | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment