Find a temporally coherent evidence path
Implement find_evidence_path(edges, start, goal, at, known_by, max_hops=3). Filter a directed graph by valid and recording times, then return evidence IDs for a deterministic shortest path.
Your task
- Each edge has source, target, valid_from, valid_to (integer or None), recorded_at, and evidence_id. Fixtures use string node/evidence IDs and integer times.
- Require max_hops to be an exact nonnegative integer; raise ValueError otherwise. Reject any edge whose non-null valid_to <= valid_from.
- An edge is eligible when valid_from <= at, valid_to is None or at < valid_to, and recorded_at <= known_by.
- Traverse eligible directed edges breadth first, ordering outgoing edges by (target, evidence_id). Use visited nodes to prevent cycles. Return the first shortest path as a list of evidence IDs.
- Return [] when start equals goal and None when no path exists within max_hops. Validate intervals before the start-equals-goal shortcut. The function assumes evidence claims are already authorized and structurally validated; it does not infer relation semantics.
Examples
EXAMPLE 1
InputA->B supported by E1 and B->C by E2, both valid and known at time 3
Output['E1','E2']
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor