Skip to content

Traversal Engine

The traversal engine performs a breadth-first search (BFS) starting from a source node and following edges up to a configurable depth.

Source node ──edge──▶ depth 1 ──edge──▶ depth 2 ──edge──▶ depth 3

At each step, visited nodes are tracked to prevent cycles.

ParameterDefaultMax
depth25
maxVisited10001000
Terminal window
GET /graphs/{graphId}/traverse?sourceId={nodeId}&depth={n}&direction={dir}
ParameterTypeDefaultDescription
sourceIdstringrequiredStarting node ID
depthnumber2Maximum traversal depth
directionoutbound | inbound | bothoutboundEdge direction to follow
edgeTypestringallFilter by edge type
{
"source": { "id": "node_1", "type": "Person", "data": { "name": "Alice" } },
"nodes": [
{ "id": "node_2", "type": "Person", "data": { "name": "Bob" }, "depth": 1 },
{ "id": "node_3", "type": "Company", "data": { "name": "Acme" }, "depth": 2 }
],
"edges": [
{ "id": "edge_1", "type": "KNOWS", "sourceId": "node_1", "targetId": "node_2" },
{ "id": "edge_2", "type": "WORKS_AT", "sourceId": "node_2", "targetId": "node_3" }
],
"visitedCount": 3,
"depthReached": 2
}
  • outbound — follow edges where the source node is the current node (default)
  • inbound — follow edges where the target node is the current node
  • both — follow all edges regardless of direction
  1. Start with depth=2 and increase only if needed.
  2. Use edgeType filter to limit the branching factor.
  3. For very large graphs (>100K nodes), use the Agentic Query endpoint which combines vector pre-filtering with traversal.