Skip to main content

Guided Labs

Complete five offline labs implementing eight graph operations with verifiable outputs. Budget 21–30 focused hours including proof, debugging and evidence. Download the Python lab package.

Extract the archive, open its graph-algorithms folder, and use Python 3.10+:

python check.py --module reference
python run_labs.py --module reference --output results-reference.json

Implement starter.py, then repeat with --module starter. The untouched starter deliberately fails. The README specifies types, errors, edge identity, numeric domains, output semantics, allowed primitives and complete cost models. Everything runs offline with the standard library.

LabRequired implementationEvidenceTime
A: structureBFS, iterative Kosaraju, Kahn orderParent edge paths, SCC partition, edge-respecting permutation or cycle failure5–7 h
B: routesDijkstra and Bellman–FordFinite path witnesses and precise unreachable/unbounded statuses5–7 h
C: connectionKruskal minimum spanning forestEdge identities, connectivity, acyclicity and optimum weight3–5 h
D: capacityEdmonds–KarpFeasible per-edge flow and equal-value residual cut5–7 h
E: reductionBipartite maximum matchingDistinct endpoints, allowed pairs, optimal cardinality and two-way proof3–4 h

Fixture interpretation​

The deterministic report gives BFS distances [0,1,2,3,null]; SCCs [[0,1],[2],[3],[4]]; no topological order for the cyclic fixture; Dijkstra distances [0,2,1,4]; Bellman–Ford [0,"unbounded","unbounded","unbounded",7,null]; forest total 1; flow value 2; and matching pairs (0,1),(1,0). Other fixtures and tests check edge cases. Alternative valid witnesses need not match the reference, but two runs of the same implementation should reproduce their report.

Falsification and repair​

Try deliberate faults: omit transpose in SCC; conflate first discovery with shortest distance; mark all reachable vertices unbounded after any negative cycle; accept cycles in a forest; omit reverse residual updates; choose a greedy maximal matching. Preserve the smallest failing graph and explain the violated invariant, then restore the correct implementation and test a fresh case.

Small exhaustive/seeded oracles and output certificates are independent feedback, not complexity proofs. Source review must establish iterative traversal semantics, heap handling, union-find bookkeeping and residual updates. A library graph call is not an implementation of the learning task; deque, heapq and sorting edge IDs are permitted primitives. Certificates and Engineering Contracts explains the proof obligations. Submit the included evidence template.