ocaml: phase 5.1 count_paths_dag.ml baseline (source-to-sink paths = 3)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Count source-to-sink paths in a DAG via Kahn's topological sort
plus accumulation:
paths[source] = 1
for u in topological order:
for v in adj[u]: paths[v] += paths[u]
Same 6-node DAG as topo_sort.ml:
0 -> {1, 2} 1 -> {3} 2 -> {3, 4} 3 -> {5} 4 -> {5}
The three witnesses 0 -> 5:
0 -> 1 -> 3 -> 5
0 -> 2 -> 3 -> 5
0 -> 2 -> 4 -> 5
Tests Queue-driven Kahn order + List.rev to recover topological
order, module-level mutable arrays (in_deg, paths), accumulation
in topological traversal.
191 baseline programs total.
This commit is contained in:
@@ -407,6 +407,17 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-11 Phase 5.1 — count_paths_dag.ml baseline (count
|
||||
source-to-sink paths in the same 6-node DAG as topo_sort.ml,
|
||||
paths 0→5 = 3). Topological sort via Kahn's (BFS), then relax
|
||||
edges in topological order: paths[v] += paths[u] for each edge
|
||||
u→v. paths[source] = 1. The three witnesses:
|
||||
0 → 1 → 3 → 5
|
||||
0 → 2 → 3 → 5
|
||||
0 → 2 → 4 → 5
|
||||
Tests Queue-driven Kahn order + List.rev to topological order,
|
||||
module-level mutable arrays (in_deg / paths), accumulation in
|
||||
topological traversal. 191 baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — stock_two.ml baseline (max stock profit
|
||||
with at most 2 transactions on [3;3;5;0;0;3;1;4] = 6). Two-pass
|
||||
DP: left[i] = max single-transaction profit in prices[0..i]
|
||||
|
||||
Reference in New Issue
Block a user