02 - Cypher Social Graph¶
This page documents the real repository example examples/02_cypher_social_graph.py.
What the Python example does¶
The script builds a generated social/work graph rather than a tiny three-node toy.
- 5,000 repeated graph patterns
- thousands of nodes
- thousands of directed
KNOWSedges - richer node properties:
name,age,active,cohort,city - richer relationship properties:
since,strength, and implicittype - SQLite and DuckDB graph reads over the same stored graph state
Main operations covered¶
- repeated
CREATEgraph writes on the SQLite route - named parameters in Cypher
CREATE - relationship alias returns
- reverse-edge matching
WHERE ... AND ...filtersORDER BYandLIMIT
Representative flow¶
db.query(
(
"CREATE (a:User {name: $a_name, age: $a_age, active: $a_active, cohort: $cohort, city: $city})"
"-[r:KNOWS {since: $since_one, strength: $strength_one}]->"
"(b:User {name: $b_name, age: $b_age, active: $b_active, cohort: $cohort, city: $city})"
),
route="sqlite",
query_type="cypher",
params={...},
)
Supported today¶
- labeled node creation
- single directed relationship creation
- narrow
MATCHflows - relationship aliases
- reverse-edge matching
WHEREequality predicates joined byANDORDER BYandLIMIT- named parameters such as
$name
Not promised yet¶
HumemDB does not claim broad Cypher compatibility today. The current surface is the tested subset described above, and unsupported constructs should fail clearly instead of being guessed at.