Skip to content

Graph Traversal

// BFS neighbourhood — center chunk + reachable neighbours within depth hops
const neighborhood: GraphNeighborhood = await indexer.getNeighborhood(chunkId, {
depth?: number, // default: 1
relationTypes?: RelationshipType[], // default: all
limit?: number, // max neighbours; default: 20
});
// Call graph
const callers: CodeChunk[] = await indexer.getCallers(chunkId);
const callees: CodeChunk[] = await indexer.getCallees(chunkId);
// Import graph
const deps: CodeChunk[] = await indexer.getDependencies('src/auth.ts');
const dependents: CodeChunk[] = await indexer.getDependents('src/auth.ts');
// Inheritance
const implementors: CodeChunk[] = await indexer.getImplementors(chunkId);
const superTypes: CodeChunk[] = await indexer.getSuperTypes(chunkId);
// Raw edge access
const outgoing: GraphEdge[] = await indexer.getEdgesFrom(chunkId, types?);
const incoming: GraphEdge[] = await indexer.getEdgesTo(chunkId, types?);

See Knowledge Graph for the full list of RelationshipType values.