OriginChain docs
examples · graph · 6 / 7

6. all_simple_paths - every node-disjoint path

← Graph examples
what 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"
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_depth and stops emitting past max_paths.
  • The number of simple paths can grow combinatorially with depth - that's why both caps exist.
common mistakes
  • Not capping max_depth. The path count is exponential in depth. Even 4-5 hops on a moderately dense graph can hit the max_paths cap immediately.
  • Using this when you only need one. If you just want the shortest, use dijkstra. If you just want yes/no, use path.