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

Function filterEdges

packages/effect/src/Graph.ts:2528–2546  ·  view source on GitHub ↗
(
  mutable: MutableGraph<N, E, T>,
  predicate: (data: E) => boolean
)

Source from the content-addressed store, hash-verified

2526 * @since 3.18.0
2527 */
2528export const filterEdges = <N, E, T extends Kind = "directed">(
2529 mutable: MutableGraph<N, E, T>,
2530 predicate: (data: E) => boolean
2531): void => {
2532 const impl = getMutableImplForMutation(mutable)
2533 const remove: Array<EdgeIndex> = []
2534
2535 internal.withTransformation(mutable, () => {
2536 // Identify edges to remove
2537 for (const [index, edgeData] of impl.edges) {
2538 if (!predicate(edgeData.data)) {
2539 remove.push(index)
2540 }
2541 }
2542 })
2543
2544 // Remove filtered out edges
2545 removeEdges(mutable, remove)
2546}
2547
2548// =============================================================================
2549// Cycle Flag Management (Internal)

Callers

nothing calls this directly

Calls 4

predicateFunction · 0.85
removeEdgesFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected