( mutable: MutableGraph<N, E, T>, nodeIndices: Iterable<NodeIndex> )
| 2731 | * @since 4.0.0 |
| 2732 | */ |
| 2733 | export const removeNodes = <N, E, T extends Kind = "directed">( |
| 2734 | mutable: MutableGraph<N, E, T>, |
| 2735 | nodeIndices: Iterable<NodeIndex> |
| 2736 | ): void => { |
| 2737 | assertMutable(mutable) |
| 2738 | if (internal.isTransforming(mutable)) { |
| 2739 | throw new GraphError({ message: "Cannot mutate graph during a transformation" }) |
| 2740 | } |
| 2741 | const indices = internal.withTransformation(mutable, () => Array.from(nodeIndices)) |
| 2742 | const impl = getMutableImplForMutation(mutable) |
| 2743 | |
| 2744 | let removed = false |
| 2745 | for (const nodeIndex of indices) { |
| 2746 | if (removeNodeInternal(impl, nodeIndex)) { |
| 2747 | removed = true |
| 2748 | } |
| 2749 | } |
| 2750 | |
| 2751 | if (removed) { |
| 2752 | invalidateCycleFlagOnRemoval(impl) |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | /** @internal */ |
| 2757 | const removeNodeInternal = <N, E, T extends Kind = "directed">( |
no test coverage detected