Hyperlinkv0.8.0-beta.28

Graph

Graph.getNodeconsteffect/Graph.ts:665
<N, E, T extends Kind = "directed">(nodeIndex: NodeIndex): (
  graph: Graph<N, E, T> | MutableGraph<N, E, T>
) => Option.Option<N>
<N, E, T extends Kind = "directed">(
  graph: Graph<N, E, T> | MutableGraph<N, E, T>,
  nodeIndex: NodeIndex
): Option.Option<N>

Gets the data associated with a node index safely, if it exists.

Example (Getting node data)

import { Graph, Option } from "effect"

const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {
  Graph.addNode(mutable, "Node A")
})

const nodeIndex = 0
const nodeData = Graph.getNode(graph, nodeIndex)

if (Option.isSome(nodeData)) {
  console.log(nodeData.value) // "Node A"
}
getters
Source effect/Graph.ts:66512 lines
export const getNode: {
  <N, E, T extends Kind = "directed">(
    nodeIndex: NodeIndex
  ): (graph: Graph<N, E, T> | MutableGraph<N, E, T>) => Option.Option<N>
  <N, E, T extends Kind = "directed">(
    graph: Graph<N, E, T> | MutableGraph<N, E, T>,
    nodeIndex: NodeIndex
  ): Option.Option<N>
} = dual(2, <N, E, T extends Kind = "directed">(
  graph: Graph<N, E, T> | MutableGraph<N, E, T>,
  nodeIndex: NodeIndex
): Option.Option<N> => graph.nodes.has(nodeIndex) ? Option.some(graph.nodes.get(nodeIndex)!) : Option.none())
Referenced by 5 symbols