Matrix Min Addition Shortest Path implementation in java