MCPcopy Create free account
hub / github.com/effect-app/libs / getDirectedNeighbors

Function getDirectedNeighbors

repos/effect/packages/effect/src/Graph.ts:1755–1778  ·  view source on GitHub ↗
(
  graph: Graph<N, E, "directed"> | MutableGraph<N, E, "directed">,
  nodeIndex: NodeIndex,
  direction: Direction
)

Source from the content-addressed store, hash-verified

1753 const impl = graphImpl(graph)
1754 const results: Array<EdgeIndex> = []
1755 for (const [edgeIndex, edgeData] of impl.edges) {
1756 if (predicate(edgeData.data, edgeData.source, edgeData.target)) {
1757 results.push(edgeIndex)
1758 }
1759 }
1760 return results
1761})
1762
1763/**
1764 * Updates a single node's data by applying a transformation function.
1765 *
1766 * **Example** (Updating node data)
1767 *
1768 * ```ts import.meta.vitest
1769 * import { Graph, Option } from "effect"
1770 *
1771 * const graph = Graph.directed<string, number>((mutable) => {
1772 * Graph.addNode(mutable, "Node A")
1773 * Graph.addNode(mutable, "Node B")
1774 * Graph.updateNode(mutable, 0, (data) => data.toUpperCase())
1775 * })
1776 *
1777 * Graph.getNode(graph, 0) // => Option.some("NODE A")
1778 * ```
1779 *
1780 * @category transforming
1781 * @since 3.18.0

Callers 5

Graph.tsFile · 0.85
isAcyclicFunction · 0.85
getTraversalNeighborsFunction · 0.85
nextMappedFunction · 0.85

Calls 2

pushMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…