First run breadth-first search from to compute each distance . All are finite by hypothesis. Next compute the strongly connected components and their condensation graph . For every component , initialize a representative minimizing over . Process components in reverse topological order, usingBreak equal-distance ties consistently, for example by fixed vertex index. Return for every .
Every vertex of one strongly connected component reaches every other; every reachable different component is reached through some first outgoing edge of . Since is a Directed acyclic graph, reverse topological order has already solved every successor. Induction over that order proves that the representative minimizes over all reachable vertices. This is minimum reachable label propagation.
All stages take time and space with explicit adjacency lists. Retaining parallel component edges is harmless: they can be scanned once each without sorting or deduplication. Reachability here includes the length-zero path, so ; this standard convention also makes the requested answer meaningful at a sink.
Articles by others on the same topic
There are currently no matching articles.