Skip to content

Add getMappedGraph and getFilteredGraph transforms - #33

Merged
davidkpiano merged 2 commits into
mainfrom
claude/effect-graph-gaps-aw57n6
Aug 17, 2026
Merged

Add getMappedGraph and getFilteredGraph transforms#33
davidkpiano merged 2 commits into
mainfrom
claude/effect-graph-gaps-aw57n6

Conversation

@davidkpiano

@davidkpiano davidkpiano commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

Adds two structural transforms to transforms.ts, rounding out the transform family (getSubgraph, getReversedGraph, getLineGraph, getFlattenedGraph):

  • getMappedGraph(graph, { node?, edge? }) — returns a new graph with node and/or edge data transformed by mapping functions. Structure (IDs, endpoints, hierarchy, ports, layout, weights) is fully preserved; only data changes. Generic over the new data types (Graph<N, E, G, P>Graph<N2, E2, G, P>), and returning undefined clears data.
  • getFilteredGraph(graph, { node?, edge? }) — returns a new graph keeping only nodes/edges that pass the given predicates. Dropping a node also drops its incident edges and strips dangling parentId/initialNodeId references, matching getSubgraph semantics (reuses the same scoping helper).

Chaining the two covers filter-then-map workflows. getSubgraph remains the ID-list form; getFilteredGraph is the predicate form.

Changes

  • src/transforms.ts: new getMappedGraph, getFilteredGraph, and their MappedGraphOptions / FilteredGraphOptions types
  • src/index.ts: export the new functions and option types
  • tests/transforms.test.ts: 8 new tests (data mapping, structure preservation, incident-edge removal, dangling-reference stripping, predicate combinations, no-op copies)
  • README.md: structural transforms list updated

Testing

  • pnpm vitest run — 1860 tests pass (82 files)
  • pnpm typecheck — clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01ATzbKkoDMTaWLqD8xZBQNv


Generated by Claude Code


Open in Devin Review

Predicate-based filtering and data-mapping transforms that preserve
graph structure, closing the map/filter API gap with effect/graph
(mapNodes/mapEdges/filterNodes/filterEdges). Dropping a node drops its
incident edges and strips dangling parent/initial references, matching
getSubgraph semantics.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATzbKkoDMTaWLqD8xZBQNv
devin-ai-integration[bot]

This comment was marked as resolved.

Forward graph-level direction and style in getMappedGraph,
getFilteredGraph, getSubgraph, and getReversedGraph so transformed
graphs keep their top-level drawing settings. Adds a changeset for the
new transforms.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATzbKkoDMTaWLqD8xZBQNv
@davidkpiano
davidkpiano merged commit 66b3828 into main Aug 17, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants