OriginChainDB
Graph

Check whether records are connected

← Graph examples

The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.

Check for a directed path between two records within a chosen number of hops.

Before you run it: False does not rule out a longer path. Reversing the endpoints can change the answer.

First load the order-to-product sample dataset. It creates shop.orders.bought_product with the exact IDs used below.

The sample dataset has a forward link from o001 to p001, so that source/target pair is reachable within one hop. The boolean result does not return the route itself.

Check whether a target is reachableA false result means no path was found within the requested traversal limit.
  1. Choose source and targetSupply both record keys and the relation.
  2. Set the maximum depthBound how many directed links can be followed.
  3. Read reachable or notThis request checks reachability rather than returning a route.

Follow the example

  1. Prepare the declared relationship.
  2. Choose starting and target keys.
  3. Set a maximum depth.
  4. Run the reachability request.

Set up the relationship

The relation must be declared in the schema's [[relations]] block. See schemas/reference#relations.

Run the request

curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/graph/shop.orders/path" \
  --data-urlencode "rel=bought_product" \
  --data-urlencode "src=o001" \
  --data-urlencode "dst=p001" \
  --data-urlencode "max_depth=3" \
  -H "Authorization: Bearer $OC_TOKEN"

Check the result

The response tells you whether a path was found within that bound.

{ "reachable": true }

One field: reachable: true | false. false means "not within max_depth" - it isn't proof there's no path at higher depth.

Understand the behavior

  • Same BFS frontier as bfs, but it stops the instant dst appears in any expansion.
  • Worst case (no path) costs the same as a bounded bfs; best case is a single hop.
  • Use this over bfs whenever you only need the boolean - the savings come from not materialising the visited set.

Important limits and checks

  • Reading false as "no path". It only means "no path within max_depth". Raise the depth only within a deliberate work limit. Simple-path enumeration is bounded too, so it does not prove unlimited reachability.
  • Swapping src and dst on a one-way relation. path is direction-sensitive. If you need the inverse direction, check that the relation is bidirectional.

Continue

Continue to find the lowest path cost.

© 2026 Silicoyn Technologies Pvt Ltd

On this page