Minimum Cost Path Matrix Java