Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while ((strLine = bReader.readLine()) != null) {
- ArrayList<Edge> temp = new ArrayList<Edge>();
- String[] spaceSep = strLine.split("\\s+");
- // empty line
- if (strLine.length() == 0) {
- System.out.print("Nothing on this line " + " --- " + count + "\n");
- if (count == 2) {
- Node n = new Node(name, start, goal, children);
- nodeTree.add(n);
- }
- // This section will handle cases where there are no
- // edges, by incrementing count, and if count is 2
- // Then a node needs to be created at this point in the
- // code
- count++;
- if (count == 2) {
- Node n = new Node(name, start, goal, children);
- nodeTree.add(n);
- // children.clear();
- }
- // reset count
- count = 0;
- }
- // non empty line
- if (strLine.length() != 0) {
- // First line, count == 0
- if (!isInteger(spaceSep[1])) {
- // clear the children so we can add the new adjacent
- // edges to the new node
- name = spaceSep[0];
- start = spaceSep[1];
- goal = spaceSep[2];
- System.out.print("Node: " + name + " " + start + " " + goal + " -- " + count + "\n");
- // do the name part
- count++;
- }
- // second line with edges, count == 1
- else if (count == 1) {
- children.clear();
- for (int i = 0; i < spaceSep.length; i = i + 2) {
- String end = spaceSep[i];
- int weight = Integer.parseInt(spaceSep[i + 1]);
- System.out.print("Edge: " + end + " " + weight + " -- " + count + "\n");
- Edge edge = new Edge(end, weight);
- children.add(edge);
- }
- count++;
- }
- }
- // Node n = new Node(name, start, goal, children);
- // //probably not here either?
- // maybe not here
- }
- Node n = new Node(name, start, goal, children);
- nodeTree.add(n);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement