javadoc and refactor for dijkstra