triangle min path reimpl