MCPcopy Create free account
hub / github.com/Effect-TS/effect / removeNodes

Function removeNodes

packages/effect/src/Graph.ts:2733–2754  ·  view source on GitHub ↗
(
  mutable: MutableGraph<N, E, T>,
  nodeIndices: Iterable<NodeIndex>
)

Source from the content-addressed store, hash-verified

2731 * @since 4.0.0
2732 */
2733export 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 */
2757const removeNodeInternal = <N, E, T extends Kind = "directed">(

Callers 2

filterMapNodesFunction · 0.85
filterNodesFunction · 0.85

Calls 5

assertMutableFunction · 0.85
removeNodeInternalFunction · 0.85
fromMethod · 0.80

Tested by

no test coverage detected