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

Function getTraversalNeighbors

packages/effect/src/Graph.ts:3750–3767  ·  view source on GitHub ↗
(
  graph: Graph<N, E, T> | MutableGraph<N, E, T>,
  nodeIndex: NodeIndex,
  direction: TraversalDirection
)

Source from the content-addressed store, hash-verified

3748}
3749
3750const getTraversalNeighbors = <N, E, T extends Kind>(
3751 graph: Graph<N, E, T> | MutableGraph<N, E, T>,
3752 nodeIndex: NodeIndex,
3753 direction: TraversalDirection
3754): Array<NodeIndex> => {
3755 if (graph.type === "undirected") {
3756 return getUndirectedNeighbors(graph as any, nodeIndex)
3757 }
3758 const directed = graph as Graph<N, E, "directed"> | MutableGraph<N, E, "directed">
3759 if (direction !== "undirected") {
3760 return getDirectedNeighbors(directed, nodeIndex, direction)
3761 }
3762 const neighbors = new Set(getDirectedNeighbors(directed, nodeIndex, "outgoing"))
3763 for (const neighbor of getDirectedNeighbors(directed, nodeIndex, "incoming")) {
3764 neighbors.add(neighbor)
3765 }
3766 return Array.from(neighbors)
3767}
3768
3769const getTraversableNeighbor = <N, E, T extends Kind>(
3770 graph: Graph<N, E, T> | MutableGraph<N, E, T>,

Callers 2

Graph.tsFile · 0.85
nextMappedFunction · 0.85

Calls 3

getUndirectedNeighborsFunction · 0.85
getDirectedNeighborsFunction · 0.85
addMethod · 0.65

Tested by

no test coverage detected