JupiterOne / starbase

Graph-based security analysis for everyone
Mozilla Public License 2.0
337 stars 32 forks source link

Adding APOC and GDS libraries to Neo4 #45

Closed adam-in-ict closed 2 years ago

adam-in-ict commented 2 years ago

Updating Docker composer file to include necessary environment values to enable GDS and APOC libraries in Neo4j database.

adam-in-ict commented 2 years ago

The added libraries do increase initial startup time of Neo4j significantly (probably an additional 30 seconds from executing yarn neo4j:start until you can connect to the database and begin using it). Once running, execution times for queries aren't impacted that I've seen.

I'll post a few examples in an additional comment before merging. Thanks!

adam-in-ict commented 2 years ago

Example APOC:

// Execute a process in small enough batch sizes that it will execute 
// even in a small memory space against millions of nodes and relationships

call apoc.periodic.iterate('MATCH (n) RETURN n', 'DETACH DELETE n', {batchSize: 1000});

example GDS:

//Determine user's centrality based on MANAGES relationships
CALL gds.graph.create('testGraph', 'User', 'MANAGES');
CALL gds.eigenvector.stream('testGraph')
  YIELD nodeId, score
  RETURN gds.util.asNode(nodeId).name AS name, score
  ORDER BY score DESC, name ASC;