Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. try (BufferedReader file = new BufferedReader(new FileReader("Distances.txt"))) {
  2. String line = file.readLine();
  3. Graph g = null;
  4. //new MatrixGraph(10);
  5. while(line != null) {
  6.  
  7. if(line.startsWith("//")){
  8. line = file.readLine();
  9. continue;
  10. }
  11. String[] characters = line.split(" +");
  12. if(g != null){
  13. g = new MatrixGraph(Integer.parseInt(characters[0]));
  14. }
  15. int i = Integer.parseInt(characters[0]);
  16. int j = Integer.parseInt(characters[1]);
  17. int d = Integer.parseInt(characters[2]);
  18. g.add(i, j, d);
  19. }
  20. line = file.readLine();
  21. file.close();
  22. bfs(g, from, to);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement