Skip to content

feat(graph): Implement Dijkstra-based pathfinding engine for format transformations#247

Merged
szmyty merged 2 commits into
mainfrom
copilot/implement-pathfinding-engine
Apr 8, 2026
Merged

feat(graph): Implement Dijkstra-based pathfinding engine for format transformations#247
szmyty merged 2 commits into
mainfrom
copilot/implement-pathfinding-engine

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Adds graph pathfinding to TransformGraph so callers can compute optimal transformation pipelines between document formats, with cost (additive) and quality (multiplicative) scoring.

Changes

src/graph/pathfinding.rs — new

  • TransformPath struct: steps: Vec<TransformEdge>, total_cost: f32 (sum), total_quality: f32 (product)

src/graph/mod.rs — extended

  • find_path(from, to) -> Option<TransformPath> — Dijkstra (A* with zero heuristic via petgraph) returning the minimum-cost path
  • find_all_paths(from, to) -> Vec<TransformPath> — enumerates all simple paths via all_simple_paths, sorted by total_cost ascending
  • edges_from_node_path — private helper that reconstructs the cheapest directed edge per node-pair, shared between both public methods

Usage

let mut graph = TransformGraph::new();
graph.add_transform(TransformEdge::new(Format::Markdown, Format::Html, 0.5, 1.0));
graph.add_transform(TransformEdge::new(Format::Html,     Format::Pdf,  0.8, 0.85));
graph.add_transform(TransformEdge::new(Format::Markdown, Format::Pdf,  5.0, 0.90));

// Optimal (cheapest) path: Markdown → Html → Pdf
let path = graph.find_path(Format::Markdown, Format::Pdf).unwrap();
assert_eq!(path.steps.len(), 2);
assert!((path.total_cost    - 1.3 ).abs() < 1e-5); // additive
assert!((path.total_quality - 0.85).abs() < 1e-5); // multiplicative

// All candidate paths, sorted cheapest first
let candidates = graph.find_all_paths(Format::Markdown, Format::Pdf);
assert_eq!(candidates.len(), 2);

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
5 tasks
- Add TransformPath struct (steps, total_cost, total_quality) in graph/pathfinding.rs
- Add find_path() using Dijkstra (A* with zero heuristic) for min-cost path
- Add find_all_paths() using all_simple_paths sorted by total_cost ascending
- Extract edges_from_node_path() helper to avoid duplication
- Export TransformPath from graph module
- Add 14 unit tests covering all pathfinding scenarios

Agent-Logs-Url: https://github.com/egohygiene/renderflow/sessions/53244046-c233-4b71-a3d3-f8cd1e49fe28

Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement pathfinding engine for format transformations feat(graph): Implement Dijkstra-based pathfinding engine for format transformations Apr 8, 2026
Copilot AI requested a review from szmyty April 8, 2026 15:08
@szmyty szmyty marked this pull request as ready for review April 8, 2026 16:59
@szmyty szmyty merged commit df729dd into main Apr 8, 2026
@devactivity-app
Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 2h 4m Pickup Time: 1h 51m Review Time: < 1 min

Achievements

@szmyty szmyty deleted the copilot/implement-pathfinding-engine branch April 8, 2026 16:59
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.

🔍 Implement pathfinding engine for format transformations

2 participants