Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. while ((strLine = bReader.readLine()) != null) {
  2. ArrayList<Edge> temp = new ArrayList<Edge>();
  3. String[] spaceSep = strLine.split("\\s+");
  4.  
  5. // empty line
  6. if (strLine.length() == 0) {
  7. System.out.print("Nothing on this line " + " --- " + count + "\n");
  8.  
  9. if (count == 2) {
  10. Node n = new Node(name, start, goal, children);
  11. nodeTree.add(n);
  12.  
  13. }
  14. // This section will handle cases where there are no
  15. // edges, by incrementing count, and if count is 2
  16. // Then a node needs to be created at this point in the
  17. // code
  18. count++;
  19. if (count == 2) {
  20. Node n = new Node(name, start, goal, children);
  21. nodeTree.add(n);
  22. // children.clear();
  23. }
  24.  
  25. // reset count
  26. count = 0;
  27. }
  28. // non empty line
  29. if (strLine.length() != 0) {
  30. // First line, count == 0
  31. if (!isInteger(spaceSep[1])) {
  32. // clear the children so we can add the new adjacent
  33. // edges to the new node
  34. name = spaceSep[0];
  35. start = spaceSep[1];
  36. goal = spaceSep[2];
  37. System.out.print("Node: " + name + " " + start + " " + goal + " -- " + count + "\n");
  38. // do the name part
  39. count++;
  40.  
  41. }
  42. // second line with edges, count == 1
  43. else if (count == 1) {
  44. children.clear();
  45. for (int i = 0; i < spaceSep.length; i = i + 2) {
  46. String end = spaceSep[i];
  47. int weight = Integer.parseInt(spaceSep[i + 1]);
  48.  
  49. System.out.print("Edge: " + end + " " + weight + " -- " + count + "\n");
  50.  
  51. Edge edge = new Edge(end, weight);
  52. children.add(edge);
  53.  
  54. }
  55. count++;
  56. }
  57.  
  58. }
  59.  
  60. // Node n = new Node(name, start, goal, children);
  61. // //probably not here either?
  62. // maybe not here
  63.  
  64. }
  65. Node n = new Node(name, start, goal, children);
  66. nodeTree.add(n);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement