Skip to content

Quick Start

Quick Start
Create your first graph from your banking data

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 — Parameters
USERNAME = "_FILL_ME_IN_" # Set your email before running
# Cell 2 — Connect
from graph_olap import GraphOLAPClient
client = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provision
from notebook_setup import provision
personas, 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.")

Now use conn.query() to run Cypher queries against the graph instance.

# List all customers in the graph
result = conn.query("""
MATCH (c:Customer)
RETURN c.id AS name, c.bk_sectr AS sector
ORDER BY c.id
""")
result.show()

Discover which customers share accounts.

# Find customers who share bank accounts
result = 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()

Use PageRank to find the most connected customers.

# Run PageRank to find the most connected customers
result = 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 results
df = conn.query_df("""
MATCH (c:Customer)
RETURN c.id AS name, round(c.pr_score, 4) AS pagerank
ORDER BY c.pr_score DESC
""")
df

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).