Graph Database Africa · The Power of the Network · live demos

Graph Lab

The three live demos from The Power of the Network, with you in control. They play on their own; click or use the arrow keys to take over.

click or → next step ← previous 1–4 jump to a question (knowledge graph) R restart (Cypher) Autoplay resumes after 30 seconds idle

Click inside the demo once so it receives your arrow keys. All patient data is fictional and for teaching only, not clinical guidance.

Run the demo yourself in Neo4j Aura Free Cypher · 6 steps

Paste into the Aura query editor one step at a time. Run step 1 twice to see MERGE vs CREATE.

// STEP 0: constraints make MERGE safe and fast
CREATE CONSTRAINT patient_id IF NOT EXISTS FOR (p:Patient) REQUIRE p.id IS UNIQUE;
CREATE CONSTRAINT isolate_id IF NOT EXISTS FOR (i:Isolate) REQUIRE i.id IS UNIQUE;
CREATE CONSTRAINT drug_name IF NOT EXISTS FOR (d:Drug) REQUIRE d.name IS UNIQUE;

// STEP 1: a patient and a specimen (MERGE = match or create; CREATE = always new)
MERGE (p:Patient {id:'PT-001'})
CREATE (s:Specimen {id:'SP-1001', type:'Blood culture'})
MERGE (p)-[:HAS_SPECIMEN {collected: date('2026-10-01')}]->(s);

// STEP 2: the lab identifies an isolate
MATCH (s:Specimen {id:'SP-1001'})
MERGE (t:LabTest {method:'MALDI-TOF'})
MERGE (s)-[:TESTED_BY]->(t)
MERGE (i:Isolate {id:'ISO-77'})
MERGE (t)-[:IDENTIFIED]->(i)
MERGE (o:Pathogen {name:'Klebsiella pneumoniae'})
MERGE (i)-[:INSTANCE_OF]->(o);

// STEP 3: a resistance mechanism is detected
MATCH (i:Isolate {id:'ISO-77'})
MERGE (m:Mechanism {name:'KPC', gene:'blaKPC'})
MERGE (i)-[:CARRIES]->(m);

// STEP 4: drug knowledge joins the graph
MATCH (m:Mechanism {name:'KPC'})
MERGE (d:Drug {name:'Meropenem'}) SET d.class = 'Carbapenem'
MERGE (m)-[:CONFERS_RESISTANCE_TO]->(d);

// STEP 5: susceptibility results live on relationships
MATCH (i:Isolate {id:'ISO-77'}), (d:Drug {name:'Meropenem'})
MERGE (c:Drug {name:'Ceftazidime-avibactam'})
MERGE (i)-[:AST_RESULT {sir:'R'}]->(d)
MERGE (i)-[:AST_RESULT {sir:'S'}]->(c);

// STEP 6: the multi-hop question
MATCH path = (:Patient {id:'PT-001'})-[:HAS_SPECIMEN]->()-[:TESTED_BY]->()
             -[:IDENTIFIED]->(:Isolate)-[:CARRIES]->(m)-[:CONFERS_RESISTANCE_TO]->(d:Drug)
RETURN m.name, d.name AS avoid, path;

// Reset when you are done
// MATCH (n) DETACH DELETE n;