Feedback on code: It is fairly hard to read.
Some more comments and better variable names might help a little.
I could follow the reading in of input. The Junctions and Paths are explained in the problem definition. What are "vertices" ?
But then I got lost at line 42 when you are in loop doing calculations:
That line looks funny to me.
Getting a junction by index based on the x value of a path!?!?
What is this loop trying to accomplish?
What do the x,y, x1,y1 represent?
Suggestions for debugging:
Add logging statements at various points to check what is happening in your internal program.
This bit also looks wrong to me.
I assume "h" and "v" are the total distance travelled horizontally and vertically within the path.
I am pretty sure
you should not be using h and v (distance travelled so far) in the Math.abs calculation. You should be looking at current and previous junctions to determine how much to add to h and v travelled to date.
Also rather than typing in the numbers each time, try the following:
It saves MASSIVE amounts of time running it if you don't have to type in the details again each time.
You should try refactoring your code to allow that a bit easier.