examples · graph · 6 / 7
6. all_simple_paths - every node-disjoint path
← Graph exampleswhat this does
Enumerates every distinct simple path from src to dst, up to max_depth hops. "Simple" means no node repeats inside a single path. Hard-capped at max_paths (default 100) so dense graphs can't blow out the response.
when to use it
- Citation networks - how does paper A cite paper B, through which intermediates?
- Dependency analysis - all routes through which X imports Y.
- Exploration / explainability - the surface to show a human "here are all the ways these two are connected".
schema requirement
The relation must be declared in the schema's [[relations]] block. See schemas/reference#relations.
the request
GET /v1/tenants/:t/graph/:schema/all_simple_paths?rel=...&src=...&dst=...&max_depth=N
curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/graph/shop.orders/all_simple_paths" \
--data-urlencode "rel=bought_product" \
--data-urlencode "src=o001" \
--data-urlencode "dst=p001" \
--data-urlencode "max_depth=3" \
-H "Authorization: Bearer $OC_TOKEN"result = db.graph.all_simple_paths(
"shop.orders",
rel="bought_product",
src="o001",
dst="p001",
max_depth=3,
)const result = await db.graph.allSimplePaths("shop.orders", {
rel: "bought_product",
src: "o001",
dst: "p001",
max_depth: 3,
});result, _ := db.Graph().AllSimplePaths(ctx, "shop.orders", originchain.AllSimplePathsRequest{
Rel: "bought_product",
Src: "o001",
Dst: "p001",
MaxDepth: 3,
}) what you get back
[
{ "pks": ["o001", "p014", "p001"] },
{ "pks": ["o001", "p027", "u091", "p001"] }
]
An array of { pks: [...] } objects, one per discovered path. pks includes both endpoints, in walk order.
how it works
- Bounded DFS from
src, tracking the path stack to enforce the "no repeated node" rule. - Stops descending past
max_depthand stops emitting pastmax_paths. - The number of simple paths can grow combinatorially with depth - that's why both caps exist.