( graph: Graph<N, E, T> | MutableGraph<N, E, T>, predicate: (data: N) => boolean )
| 579 | * @category getters |
| 580 | */ |
| 581 | export const findNode = <N, E, T extends Kind = "directed">( |
| 582 | graph: Graph<N, E, T> | MutableGraph<N, E, T>, |
| 583 | predicate: (data: N) => boolean |
| 584 | ): Option.Option<NodeIndex> => { |
| 585 | for (const [index, data] of graph.nodes) { |
| 586 | if (predicate(data)) { |
| 587 | return Option.some(index) |
| 588 | } |
| 589 | } |
| 590 | return Option.none() |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * Finds all nodes that match the given predicate. |
nothing calls this directly
no test coverage detected