Dynamic programming and minimum risk paths