Shortest Path Routing Algorithm In Java