Quick Start
Quick Start
Create your first graph from your banking data
Step 1: Connect to the Tutorial Graph
Section titled “Step 1: Connect to the Tutorial Graph”The Graph OLAP SDK has two parts: a control plane (manages resources) and wrapper instances (run queries). The setup() helper connects to the control plane and finds or creates the shared tutorial instance.
# Cell 1 — ParametersUSERNAME = "_FILL_ME_IN_" # Set your email before running# Cell 2 — Connectfrom graph_olap import GraphOLAPClientclient = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provisionfrom notebook_setup import provisionpersonas, conn = provision(USERNAME)analyst = personas["analyst"]admin = personas["admin"]ops = personas["ops"]client = analyst
print(f"Connected! Graph has {conn.query_scalar('MATCH (n) RETURN count(n)')} nodes.")Step 2: Query Your Graph
Section titled “Step 2: Query Your Graph”Now use conn.query() to run Cypher queries against the graph instance.
# List all customers in the graphresult = conn.query(""" MATCH (c:Customer) RETURN c.id AS name, c.bk_sectr AS sector ORDER BY c.id""")result.show()Step 3: Find Connections
Section titled “Step 3: Find Connections”Discover which customers share accounts.
# Find customers who share bank accountsresult = conn.query(""" MATCH (a:Customer)-[:SHARES_ACCOUNT]->(b:Customer) RETURN a.id AS customer_1, b.id AS customer_2 ORDER BY a.id""")
result.show()Step 4: Run an Algorithm
Section titled “Step 4: Run an Algorithm”Use PageRank to find the most connected customers.
# Run PageRank to find the most connected customersresult = conn.algo.pagerank( node_label="Customer", property_name="pr_score", edge_type="SHARES_ACCOUNT",)print(f"Algorithm status: {result.status}")print(f"Nodes updated: {result.nodes_updated}")
# Query the resultsdf = conn.query_df(""" MATCH (c:Customer) RETURN c.id AS name, round(c.pr_score, 4) AS pagerank ORDER BY c.pr_score DESC""")dfCleanup
Section titled “Cleanup”The tutorial instance has a TTL (time-to-live) and will be automatically deleted when it expires. No manual cleanup is needed.
To delete it early, use client.instances.delete(instance.id).