Outage Blast Radius (Go)
Topics: graphs, BFS, resilience
Problem
You have a service call graph — graph[svc] lists the services that svc calls (depends on). When
one service fails, every service that transitively depends on it is impacted. Compute the blast
radius: each impacted service and how many hops away it is.
func BlastRadius(graph map[string][]string, failed string) map[string]int
- Return every service transitively impacted when
failed goes down, mapped to its shortest hop
distance (1 = a direct caller of failed).
- Exclude
failed itself; omit services that aren't impacted.
- The graph may contain cycles — don't loop forever.
web→api, api→{db,cache}, worker→db
BlastRadius(graph, "db") → {api:1, worker:1, web:2} // cache is unaffected
This is a breadth-first search over the reversed graph (callee → callers): build the reverse
adjacency, then BFS from failed so first-visit distances are the shortest.
Run
go test -v ./challenges/blast-radius/go/
Sign in to submit your solution.