I am afraid that code shows the hazards of poor naming. Things like e.w are impossible to understand. That is why you should always give variables meaningful names. It also does not show which class the remove method is in. It should be in whichever class models the path, so it can take care of itself. Also you should give fields private access (except for global constants), so things like e.w might fail to compile. Also look at our
style suggestions about spacing; you should put more spaces in the heading of your for loop.
Maybe each Edge should keep a reference to its start and finish nodes, or maybe you should use a different type of List. Why are you using a singly‑linked list?
Are you deleting all the nodes from position
n ot the end? If so, can you simply delete node
n (=set next to
null in
n − 1) and let the rest of the list become unreachable and eligible for garbage collection?