* Get neighboring vertices based on direction.
(
source: GraphSource<any>,
vertex: Vertex<any, any>,
direction: Direction,
edgeLabels: readonly string[],
)
| 5300 | * Get neighboring vertices based on direction. |
| 5301 | */ |
| 5302 | private getNeighbors( |
| 5303 | source: GraphSource<any>, |
| 5304 | vertex: Vertex<any, any>, |
| 5305 | direction: Direction, |
| 5306 | edgeLabels: readonly string[], |
| 5307 | ): Array<{ vertex: Vertex<any, any>; edge: Edge<any, any> }> { |
| 5308 | const results: Array<{ vertex: Vertex<any, any>; edge: Edge<any, any> }> = []; |
| 5309 | |
| 5310 | if (direction === "out" || direction === "both") { |
| 5311 | // Outgoing edges: vertex is the source (outV), return target (inV) |
| 5312 | for (const edge of source.getOutgoingEdges(vertex.id)) { |
| 5313 | if (edgeLabels.length === 0 || edgeLabels.includes(edge.label)) { |
| 5314 | results.push({ vertex: edge.inV, edge }); |
| 5315 | } |
| 5316 | } |
| 5317 | } |
| 5318 | |
| 5319 | if (direction === "in" || direction === "both") { |
| 5320 | // Incoming edges: vertex is the target (inV), return source (outV) |
| 5321 | for (const edge of source.getIncomingEdges(vertex.id)) { |
| 5322 | if (edgeLabels.length === 0 || edgeLabels.includes(edge.label)) { |
| 5323 | results.push({ vertex: edge.outV, edge }); |
| 5324 | } |
| 5325 | } |
| 5326 | } |
| 5327 | |
| 5328 | return results; |
| 5329 | } |
| 5330 | |
| 5331 | /** |
| 5332 | * Check if a vertex matches the target criteria. |
no test coverage detected