effect-graph

Build, traverse, and analyze immutable graphs with Effect's Graph module.

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-graph-mpsuesser
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-graph
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-graph
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-graph-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Modeling dependency graphs, task ordering, reachability, and shortest paths in TypeScript often leads to ad-hoc mutable structures and hand-rolled traversal bugs. This Skill teaches the agent to use Effect's Graph module correctly, covering its immutable data model, scoped mutation, lazy walkers, and algorithm APIs so graph code is correct on the first pass. ## Core Features & Use Cases - Graph construction and scoped mutation: Create directed or undirected graphs with Graph.directed/Graph.undirected, and apply batched writes through Graph.mutate with addNode, addEdge, removeNode, and bulk map/filter transforms. - Traversal and analysis: Run lazy DFS, BFS, postorder, and topological walkers, detect cycles with isAcyclic and stronglyConnectedComponents, and compute connectivity, bridges, and bipartite matchings. - Shortest paths and visualization: Compute routes with Dijkstra, A*, Bellman-Ford, and Floyd-Warshall, then export diagrams via Graph.toGraphViz and Graph.toMermaid. - Use Case: Given a build system where tasks depend on each other, model the tasks as a directed graph, detect dependency cycles via strongly connected components, and emit a valid execution order with Graph.topo. ## Quick Start Use the effect-graph skill to model my task dependencies as a directed graph, check for cycles, and produce a topological execution order.

Frequently Asked Questions about effect-graph

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I topologically sort tasks with Effect Graph?

Build a directed graph where edge A to B means A runs before B, then call Graph.topo(graph) and collect the walker with Graph.indices. Guard with Graph.isAcyclic first, since topo throws GraphError on cyclic or undirected graphs.

How do I detect dependency cycles in a directed graph?

Use Graph.isAcyclic for a boolean check, or Graph.stronglyConnectedComponents to find the actual cycles. Any SCC with more than one node represents a dependency cycle; Graph.findCycle returns a concrete closed node path with edge indexes.

Does Effect Graph support shortest path algorithms?

Yes. Graph.dijkstra and Graph.astar handle non-negative weights, Graph.bellmanFord allows negative weights, and Graph.floydWarshall computes all-pairs paths. Dijkstra and A* validate every edge weight eagerly and throw GraphError on any negative or NaN cost.

Why does Graph.addEdge throw a GraphError?

Graph.addEdge throws GraphError when either endpoint node index does not exist in the mutable graph. The Graph module is fully synchronous: invalid operations throw, while lookups like getNode and getEdge return Option instead.

Can I mutate an immutable Effect Graph directly?

No. Write APIs require a MutableGraph obtained through the constructor callback, Graph.mutate, or beginMutation. Graph.mutate copies the graph, applies your changes, and returns a new immutable graph, leaving the original unchanged.

How do I export an Effect Graph to Mermaid or GraphViz?

Call Graph.toMermaid(graph, options) or Graph.toGraphViz(graph, options), both of which return a string. Options customize node and edge labels, diagram direction, and node shapes; directed graphs render as flowcharts and undirected graphs as plain graphs.