| 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; |