Loading...
Loading...
Run Neo4j Graph Analytics algorithms (PageRank, Louvain, WCC, Dijkstra, KNN, Node2Vec, FastRP, GraphSAGE) directly inside Snowflake without moving data. Use when running graph algorithms against Snowflake tables via the Neo4j Snowflake Native App ("GDS Snowflake", "graph algorithms in Snowflake", "Neo4j Graph Analytics"). Covers installation, privilege setup, project-compute-write pattern, and SQL CALL syntax. Does NOT cover Cypher or Neo4j DBMS queries — use neo4j-cypher-skill. Does NOT cover Aura Graph Analytics — use neo4j-aura-graph-analytics-skill. Does NOT cover self-managed GDS — use neo4j-gds-skill.
npx skill4agent add neo4j-contrib/neo4j-skills neo4j-snowflake-graph-analytics-skillCALLneo4j-gds-skillneo4j-aura-graph-analytics-skillneo4j-gds-skillneo4j-cypher-skill| Table type | Required columns | Optional columns |
|---|---|---|
| Node table | | Any additional columns become node properties |
| Relationship table | | Any additional columns become relationship properties |
nodeIdsourceNodeIdtargetNodeIdorientationNATURALUNDIRECTEDREVERSENeo4j_Graph_AnalyticsCREATE COMPUTE POOLCREATE WAREHOUSE-- Step 1: Use ACCOUNTADMIN to set up roles and grants
USE ROLE ACCOUNTADMIN;
-- Create a consumer role for users of the application
CREATE ROLE IF NOT EXISTS MY_CONSUMER_ROLE;
GRANT APPLICATION ROLE Neo4j_Graph_Analytics.app_user TO ROLE MY_CONSUMER_ROLE;
SET MY_USER = (SELECT CURRENT_USER());
GRANT ROLE MY_CONSUMER_ROLE TO USER IDENTIFIER($MY_USER);
-- Step 2: Create a database role and grant it to the app
USE DATABASE MY_DATABASE;
CREATE DATABASE ROLE IF NOT EXISTS MY_DB_ROLE;
GRANT USAGE ON DATABASE MY_DATABASE TO DATABASE ROLE MY_DB_ROLE;
GRANT USAGE ON SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT SELECT ON ALL TABLES IN SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT SELECT ON ALL VIEWS IN SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT SELECT ON FUTURE TABLES IN SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT SELECT ON FUTURE VIEWS IN SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT CREATE TABLE ON SCHEMA MY_DATABASE.MY_SCHEMA TO DATABASE ROLE MY_DB_ROLE;
GRANT DATABASE ROLE MY_DB_ROLE TO APPLICATION Neo4j_Graph_Analytics;
-- Step 3: Grant the consumer role access to output tables
GRANT USAGE ON DATABASE MY_DATABASE TO ROLE MY_CONSUMER_ROLE;
GRANT USAGE ON SCHEMA MY_DATABASE.MY_SCHEMA TO ROLE MY_CONSUMER_ROLE;
GRANT SELECT ON FUTURE TABLES IN SCHEMA MY_DATABASE.MY_SCHEMA TO ROLE MY_CONSUMER_ROLE;
-- Step 4: Switch to the consumer role to run algorithms
USE ROLE MY_CONSUMER_ROLE;Replace,P2P,PUBLIC, andGRAPH_USER_ROLEwith your actual names throughout.GRAPH_DB_ROLE
-- Optional: set default database to avoid fully-qualified names
USE DATABASE Neo4j_Graph_Analytics;
USE ROLE GRAPH_USER_ROLE;
-- Call WCC (Weakly Connected Components)
CALL Neo4j_Graph_Analytics.graph.wcc('CPU_X64_XS', {
'defaultTablePrefix': 'P2P.PUBLIC',
'project': {
'nodeTables': ['USER_VW'],
'relationshipTables': {
'AGG_TRANSACTIONS_VW': {
'sourceTable': 'P2P.PUBLIC.USER_VW',
'targetTable': 'P2P.PUBLIC.USER_VW',
'orientation': 'NATURAL'
}
}
},
'compute': { 'consecutiveIds': true },
'write': [{
'nodeLabel': 'NODES',
'outputTable': 'USER_COMPONENTS'
}]
});
-- Inspect results
SELECT * FROM P2P.PUBLIC.USER_COMPONENTS;| Pool | Use |
|---|---|
| Dev / small graphs |
| Progressively larger |
| Large graphs, lower CPU need |
| Compute-intensive (GraphSAGE); GPU not available in all regions |
| Algorithm | Procedure | Use case |
|---|---|---|
| Weakly Connected Components | | Find disconnected subgraphs |
| Louvain | | Community detection, modularity optimisation |
| Leiden | | Improved community detection (more stable than Louvain) |
| K-Means Clustering | | Cluster nodes by node properties |
| Triangle Count | | Measure local clustering / detect dense subgraphs |
| Algorithm | Procedure | Use case |
|---|---|---|
| PageRank | | Rank nodes by influence |
| Article Rank | | PageRank variant, discounts high-degree neighbours |
| Betweenness Centrality | | Find bridge nodes in a network |
| Degree Centrality | | Count direct connections per node |
| Algorithm | Procedure | Use case |
|---|---|---|
| Dijkstra Source-Target | | Shortest path between two nodes |
| Dijkstra Single-Source | | Shortest paths from one node to all others |
| Delta-Stepping SSSP | | Faster parallel shortest paths |
| Breadth First Search | | BFS traversal from a source node |
| Yen's K-Shortest Paths | | Top-K shortest paths between two nodes |
| Max Flow | | Maximum flow through a network |
| FastPath | | Fast approximate shortest paths |
| Algorithm | Procedure | Use case |
|---|---|---|
| Node Similarity | | Find similar nodes based on shared neighbours |
| Filtered Node Similarity | | Node similarity with source/target filters |
| K-Nearest Neighbors | | Find K most similar nodes |
| Filtered KNN | | KNN with source/target filters |
| Algorithm | Procedure | Use case |
|---|---|---|
| Fast Random Projection (FastRP) | | Fast node embeddings |
| Node2Vec | | Random-walk-based node embeddings |
| HashGNN | | GNN-inspired embeddings without training |
| GraphSAGE (train) | | Train inductive node embeddings |
| GraphSAGE (predict) | | Predict with a trained GraphSAGE model |
| Node Classification (train) | | Supervised node label prediction |
| Node Classification (predict) | | Apply trained node classifier |
{
"project": {
"nodeTables": [
"DB.SCHEMA.TABLE_A",
"DB.SCHEMA.TABLE_B"
],
"relationshipTables": {
"DB.SCHEMA.REL_TABLE": {
"sourceTable": "DB.SCHEMA.TABLE_A",
"targetTable": "DB.SCHEMA.TABLE_B",
"orientation": "NATURAL"
}
}
}
}defaultTablePrefixweight{
"write": [
{
"nodeLabel": "TABLE_A",
"outputTable": "DB.SCHEMA.OUTPUT_TABLE",
"nodeProperty": "score"
}
]
}nodeLabeloutputTablenodeProperty{
"write": [
{
"relationshipType": "SIMILAR",
"outputTable": "DB.SCHEMA.SIMILARITY_OUTPUT"
}
]
}FUTURE TABLES-- Step 1: Run FastRP to generate embeddings
CALL Neo4j_Graph_Analytics.graph.fastrp('CPU_X64_XS', { ... });
-- Step 2: Run KNN on the embedding output
CALL Neo4j_Graph_Analytics.graph.knn('CPU_X64_XS', { ... });CREATE VIEW MY_SCHEMA.NODES_VIEW AS
SELECT user_id AS nodeId, name, age
FROM MY_SCHEMA.USERS;
CREATE VIEW MY_SCHEMA.RELS_VIEW AS
SELECT from_user AS sourceNodeId, to_user AS targetNodeId, weight
FROM MY_SCHEMA.CONNECTIONS;| Problem | Solution |
|---|---|
| Check the app has |
| Your table is missing the required column — create a view that aliases it |
| The pool may still be starting up; wait a minute and retry |
| Algorithm returns no results | Check your node/relationship tables are not empty and projections are correct |