Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try (BufferedReader file = new BufferedReader(new FileReader("Distances.txt"))) {
- String line = file.readLine();
- Graph g = null;
- //new MatrixGraph(10);
- while(line != null) {
- if(line.startsWith("//")){
- line = file.readLine();
- continue;
- }
- String[] characters = line.split(" +");
- if(g != null){
- g = new MatrixGraph(Integer.parseInt(characters[0]));
- }
- int i = Integer.parseInt(characters[0]);
- int j = Integer.parseInt(characters[1]);
- int d = Integer.parseInt(characters[2]);
- g.add(i, j, d);
- }
- line = file.readLine();
- file.close();
- bfs(g, from, to);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement