import java.io.*; import java.util.*; public class Path { public static void main(String args[]) { int from = 0; int to = 0; if(args.length > 1) { from = Integer.parseInt(args[0]); to = Integer.parseInt(args[1]); } try { ListGraph graph = createGraph("Distances.txt"); findShortestWay(from, to); } catch(IOException e) { System.err.println("Warning! Exception: "+e.toString()); } } private static ListGraph createGraph(String filename) throws IOException { ListGraph graph = null; Scanner in = new Scanner(new File(filename)); String tmp; while(in.hasNext()) { tmp = in.nextLine(); if(tmp.length() > 0) { String[] data = tmp.split(" +"); System.out.println(Arrays.toString(data)); if(isInt(data[0]) && graph == null) { graph = new ListGraph(Integer.parseInt(data[0])); } else if(isInt(data[0]) && isInt(data[1]) && isInt(data[2])) { graph.addEdge(Integer.parseInt(data[0]), Integer.parseInt(data[0]), Integer.parseInt(data[0])); } } } return graph; } private static boolean isInt(String word) throws IOException { char[] wordChars = word.toCharArray();; for(int i=0; i