MCPcopy Create free account
hub / github.com/codemix/graph / traverse

Method traverse

packages/graph/src/Steps.ts:4346–4381  ·  view source on GitHub ↗
(
    source: GraphSource<any>,
    input: Iterable<unknown>,
    _context?: QueryContext,
  )

Source from the content-addressed store, hash-verified

4344 }
4345
4346 public *traverse(
4347 source: GraphSource<any>,
4348 input: Iterable<unknown>,
4349 _context?: QueryContext,
4350 ): IterableIterator<unknown> {
4351 const seenV = new Set<ElementId>();
4352 const seenE = new Set<ElementId>();
4353
4354 for (const path of input) {
4355 this.traversed++;
4356 if (!(path instanceof TraversalPath)) continue;
4357 const { value } = path;
4358 if (value instanceof Vertex) {
4359 seenV.add(value.id);
4360 } else if (value instanceof Edge) {
4361 seenE.add(value.id);
4362 }
4363 }
4364
4365 for (const path of this.intersectTraverser.traverse(source, input)) {
4366 this.traversed++;
4367 if (!(path instanceof TraversalPath)) continue;
4368 const { value } = path;
4369 if (value instanceof Vertex) {
4370 if (seenV.has(value.id)) {
4371 this.emitted++;
4372 yield path;
4373 }
4374 } else if (value instanceof Edge) {
4375 if (seenE.has(value.id)) {
4376 this.emitted++;
4377 yield path;
4378 }
4379 }
4380 }
4381 }
4382
4383 public override clone(partial?: Partial<IntersectStepConfig>) {
4384 const { config, steps } = this;

Callers

nothing calls this directly

Calls 3

addMethod · 0.65
traverseMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected