( graph: Graph<N, E, "directed"> | MutableGraph<N, E, "directed">, nodeIndex: NodeIndex, direction: Direction )
| 2621 | ): number => graphImpl(graph).edges.size |
| 2622 | |
| 2623 | const getDirectedNeighbors = <N, E>( |
| 2624 | graph: Graph<N, E, "directed"> | MutableGraph<N, E, "directed">, |
| 2625 | nodeIndex: NodeIndex, |
| 2626 | direction: Direction |
| 2627 | ): Array<NodeIndex> => { |
| 2628 | const impl = graphImpl(graph) |
| 2629 | const adjacencyMap = direction === "incoming" |
| 2630 | ? impl.reverseAdjacency |
| 2631 | : impl.adjacency |
| 2632 | |
| 2633 | const adjacencyList = adjacencyMap.get(nodeIndex) |
| 2634 | if (adjacencyList === undefined) { |
| 2635 | return [] |
| 2636 | } |
| 2637 | |
| 2638 | const result: Array<NodeIndex> = [] |
| 2639 | for (const edgeIndex of adjacencyList) { |
| 2640 | const edge = impl.edges.get(edgeIndex) |
| 2641 | if (edge !== undefined) { |
| 2642 | result.push(direction === "incoming" ? edge.source : edge.target) |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | return result |
| 2647 | } |
| 2648 | |
| 2649 | /** |
| 2650 | * Returns the neighboring node indices for a node. |
no test coverage detected