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

Function reverse

packages/effect/src/Graph.ts:892–912  ·  view source on GitHub ↗
(
  mutable: MutableGraph<N, E, T>
)

Source from the content-addressed store, hash-verified

890 * @category transformations
891 */
892export const reverse = <N, E, T extends Kind = "directed">(
893 mutable: MutableGraph<N, E, T>
894): void => {
895 if (mutable.type === "undirected") {
896 return
897 }
898
899 // Reverse all edges by swapping source and target
900 for (const [index, edgeData] of mutable.edges) {
901 mutable.edges.set(index, {
902 source: edgeData.target,
903 target: edgeData.source,
904 data: edgeData.data
905 })
906 }
907
908 rebuildAdjacency(mutable)
909
910 // Invalidate cycle flag since edge directions changed
911 mutable.isAcyclic = Option.none()
912}
913
914/**
915 * Filters and optionally transforms nodes in a mutable graph using a predicate function.

Callers

nothing calls this directly

Calls 2

rebuildAdjacencyFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected