Maximum-product edge-labelled walk

ID: maximum-product-edge-labelled-walk

Attach nonnegative edge scores to edge-labelled walk matching. For each layer and endpoint, keep the greatest product over matching prefixes. Only edges with the required current label enter the maximum. Multiplication by a nonnegative score preserves order, proving the dynamic programming recurrence. Store a predecessor for each reachable layer entry to recover a maximizing walk. A reachable score of zero must be distinguished from no matching walk: keep reachability separately or use an impossible negative sentinel and skip it before multiplication. The score is the defined product; interpreting it as a physical event probability can require extra independence assumptions.

New to topics? Read the docs here!