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

Function filterEdges

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

Source from the content-addressed store, hash-verified

2190 * @since 3.18.0
2191 */
2192export const filterEdges = <N, E, T extends Kind = "directed">(
2193 mutable: MutableGraph<N, E, T>,
2194 predicate: (data: E) => boolean
2195): void => {
2196 assertMutable(mutable)
2197 const impl = graphImpl(mutable)
2198
2199 const edgesToRemove: Array<EdgeIndex> = []
2200
2201 // Identify edges to remove
2202 for (const [index, edgeData] of impl.edges) {
2203 if (!predicate(edgeData.data)) {
2204 edgesToRemove.push(index)
2205 }
2206 }
2207
2208 // Remove filtered out edges
2209 for (const edgeIndex of edgesToRemove) {
2210 removeEdge(mutable, edgeIndex)
2211 }
2212}
2213
2214// =============================================================================
2215// Cycle Flag Management (Internal)

Callers

nothing calls this directly

Calls 5

assertMutableFunction · 0.85
graphImplFunction · 0.85
predicateFunction · 0.85
removeEdgeFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected