Explore Dependencies Within Limits
Open the bounded traversal example to compare dependencies, dependents and partial results on a cyclic service graph.
@graphora/analytics operates on a supplied core snapshot. It does not change selection, styles, graph data or the camera. You decide how to present its results.
Discover A Neighborhood
import { traverseNeighborhood, getTraversalPath } from '@graphora/analytics'
const result = traverseNeighborhood(engine.store.snapshot(), 'api', {
direction: 'out',
maxDepth: 2,
maxNodes: 100,
maxEdgeVisits: 10000
})
for (const visit of result.visits) {
console.log(visit.nodeId, visit.depth, getTraversalPath(result, visit.nodeId))
}The root has depth zero. Each later visit has its minimum hop distance and one parentNodeId / parentEdgeId. Parallel edges are distinguished by their IDs; the first qualifying edge in snapshot order determines the parent. Cycles and self-loops never rediscover nodes. getTraversalPath reconstructs a frozen { nodeIds, edgeIds } route through these parents, or returns null for a node outside the result. It describes one unweighted traversal route.
Input IDs use core normalization, so numeric 1 and string "1" find the same node. Output preserves stored ID representations. A missing root produces an empty result with rootId: null.
Direction And Graph Scope
outfollows directed edges from source to target and is the default.infollows directed edges from target to source.bothfollows either orientation.
Undirected edges can be crossed both ways in every mode, matching the existing analytics helpers. Core adjacency selectors and runtime collections instead use stored source/target orientation even for undirected edges.
The supplied snapshot defines the complete analysis scope. Pass source topology to include all supplied source nodes, or a visible subset to restrict exploration. A missing node cannot become a bridge through the subset. Recompute when the chosen topology changes. graphVersion is diagnostic information, not an engine view-provenance token; changes to view filters may require new results without a source version change.
Explain Partial Results
Defaults are maxDepth: 2, maxNodes: 1000 and maxEdgeVisits: 10000. maxNodes includes the starting node. Depth/work limits accept nonnegative safe integers; the node limit must be positive. Invalid options throw GraphError with INVALID_GRAPH and the option's field name in its issues.
truncated and limitReasons explain encountered limits:
| Reason | Meaning |
|---|---|
depth | At least one undiscovered neighbor was beyond the hop boundary. |
nodes | Another discovered candidate would exceed the service/node budget. |
edges | Adjacency work was stopped; further reachability was not verified. |
Reaching a numeric limit exactly does not necessarily mean incomplete results. For example, a root with no outgoing edges is complete even at depth zero. Work-limited output may already contain all reachable nodes; it is not certified as a completed traversal. Do not label partial output as an exhaustive dependency list. Show its limits and let users increase them or narrow the graph scope.
Each inspected adjacency entry consumes work, including loops and already-visited parallel destinations. A self-loop has one entry at its node. Index construction still visits the supplied nodes and edges in O(V + E) time and space before the bounded walk, so the work budget is not a hard elapsed-time bound or a substitute for background execution. Parent records avoid storing every full path eagerly.
Connect Results To A View
The example keeps gray context nodes, colors the root blue and reached nodes amber, and highlights only the parent edges recorded in the result. Its table shows distances and exact route edges. It builds one core batch of style-attribute updates through the public engine store. Applications may instead feed IDs into their existing selection/highlight state.
Existing analytics also include degree metrics, weakly connected components, breadthFirstTraversal returning node IDs and shortestPath for an unweighted node route. Those APIs retain their existing behavior.