Graph examples
← All examplesOriginChainDB exposes graph traversal and the graph algorithms built on top of it, all over the same declared relations. The traversals - neighbors, reverse, bfs, path and dijkstra - read an adjacency index laid down at write time rather than computed per query. The algorithms above them cover ranked paths, community detection, centrality and node embeddings.
17 work today. Each example below is its own page, with the request, the response shape, side-by-side cURL / Python / TypeScript / Go, and the mistakes that produce a 404 or an empty result.
Every endpoint below requires a [[relations]] block on the schema - the relation must be declared before any traversal can resolve. See schemas/reference#relations for the shape. Without a matching relation the call is refused rather than quietly returning an empty result.
Direct adjacency-list lookup. The fastest graph query on the substrate - one hop, one read.
Who points at this row? The mirror of neighbors. Requires bidirectional=true on the relation (default).
Every node reachable within max_depth hops, with the depth at which each was found.
Is X connected to Y at all? Returns a boolean. Short-circuits on the first match.
Single shortest-path cost between two nodes under a caller-supplied edge-weight map.
Every distinct path from src to dst. Hard-capped at max_paths to avoid exponential blowup.
PageRank scores over a subgraph you scope explicitly via the nodes= parameter.
Every closed triple in the relation, walked as undirected. One row per triangle, keys in canonical order.
Union-find over the whole node universe. One entry per node carrying the id of the island it landed in.
The dense groups inside a connected graph, as deterministic integer ids in a communities envelope.
Near-linear community detection. Order-sensitive, so pass a seed when you need to reproduce a run.
Which nodes sit on the most shortest paths. Exact by default, with an opt-in sampled mode for big graphs.
Influence weighted by the influence of your neighbours. No node universe to supply, unlike pagerank.
Yen's ranked alternatives between two nodes. Note the source and target parameter names, not src and dst.
A deterministic walk from a start node, with optional p and q bias. The seed is a required parameter.
Learn a vector per node from biased walks, persist it, then ask for the nodes most similar to any node.
Embeddings that combine the graph with a numeric feature column on each row. Train, persist, then query.