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

Function nextMapped

repos/effect/packages/effect/src/Graph.ts:4280–4307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4278 * edge weight is `NaN` or `-Infinity`, or if any negative cycle is detected.
4279 *
4280 * **Example** (Finding all-pairs shortest paths)
4281 *
4282 * ```ts import.meta.vitest
4283 * import { Graph } from "effect"
4284 *
4285 * const graph = Graph.directed<string, number>((mutable) => {
4286 * const a = Graph.addNode(mutable, "A")
4287 * const b = Graph.addNode(mutable, "B")
4288 * const c = Graph.addNode(mutable, "C")
4289 * Graph.addEdge(mutable, a, b, 3)
4290 * Graph.addEdge(mutable, b, c, 2)
4291 * Graph.addEdge(mutable, a, c, 7)
4292 * })
4293 *
4294 * const result = Graph.floydWarshall(graph, (edgeData) => edgeData)
4295 * const shortest = { distance: result.distances.get(0)?.get(2), path: result.paths.get(0)?.get(2) }
4296 * shortest // => { distance: 5, path: [0, 1, 2] }
4297 * ```
4298 *
4299 * @category algorithms
4300 * @since 3.18.0
4301 */
4302export const floydWarshall: {
4303 <E>(
4304 cost: (edgeData: E) => number
4305 ): <N, T extends Kind = "directed">(graph: Graph<N, E, T> | MutableGraph<N, E, T>) => AllPairsResult<E>
4306 <N, E, T extends Kind = "directed">(
4307 graph: Graph<N, E, T> | MutableGraph<N, E, T>,
4308 cost: (edgeData: E) => number
4309 ): AllPairsResult<E>
4310} = dual(2, <N, E, T extends Kind = "directed">(

Callers

nothing calls this directly

Calls 9

getTraversalNeighborsFunction · 0.85
getDirectedNeighborsFunction · 0.85
pushMethod · 0.80
addMethod · 0.65
getMethod · 0.65
setMethod · 0.65
nextMethod · 0.65
fFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…