public static void main(String[] args) { String inputFileName = args[0]; String rootNode = args[1]; AdjacencyList adjacencyList = new AdjacencyList(inputFileName); nodes.addAll(adjacencyList.getAdjacencyList().keySet()); Map<Node, List<Edge>> list = adjacencyList.getAdjacencyList(); for (Node node : list.keySet()) { List<Edge> edgeList = list.get(node); edges.addAll(edgeList); } // print header System.out.println("Node \t Cost \t Next-Hop"); // perform dijkstras for each node as the destination from the root node Node source = null; for (Node node : adjacencyList.getAdjacencyList().keySet()) { if (node.getAddr() == Integer.valueOf(rootNode)) { source = node; break; } } if (source != null) { execute(source); } for (Node node : adjacencyList.getAdjacencyList().keySet()) { if (node.getAddr() != source.getAddr()) { LinkedList<Node> path = getPath(node); System.out.println( node.getAddr() + " \t " + distance.get(node) + " \t " + path.get(1).getAddr()); } } }