Getting Started

Tutorial: Building with CleaveDB

Confidence & Affinity

Real-world relationships are not always binary true-or-false flags. Recommendation systems, fraud detection models, and social affinity graphs require weighted edges that quantify the strength, confidence, or probability of a connection. CleaveDB supports floating-point weights natively on graph bonds via WITH CONFIDENCE and WITH AFFINITY.

Attaching confidence and affinity scores

Assign floating-point scores between 0.0 and 1.0 to any bond statement:

CleaveQLExample · Bond with confidence and affinity
-- Confidence score (e.g. recommendation probability)
BOND "users:alice" TO "products:p12" AS "recommended" WITH CONFIDENCE 0.9

-- Affinity score (e.g. social closeness)
BOND "users:alice" TO "users:bob" AS "collaborator" WITH AFFINITY 0.8

-- Combining both scores on a single bond
BOND "emp:e1" TO "emp:e2" AS "colleague" WITH CONFIDENCE 0.9 WITH AFFINITY 0.7

The weights are stored directly in the physical graph edge index in _bonds, allowing fast sorting and filtering during traversal.

Filtering traversals by threshold

Query graph paths that meet or exceed a confidence cutoff using GUIDED THRESHOLD:

CleaveQLExample · Traverse high-confidence recommendations
FIND "recommended" OF "users:alice" GUIDED THRESHOLD 0.8

CleaveDB prunes edges with weights below 0.8 at the hardware vector register layer, returning only top-tier recommendations.