Path class for O(1) path cost