Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ArrayList<node> loadNode(String path) throws IOException
- {
- int size = getSizeNode(path);
- int[][] vert = loadVert(path, size);
- ArrayList<node> nodes = new ArrayList<node>();
- //create nodes 1 through 1000...something only need about 600
- for(int i = 0; i < size; i++)
- {
- node n = new node(i);
- nodes.add(n);
- }
- //create the connections
- BufferedReader in = new BufferedReader(new FileReader(path));
- //for(int i = 0; i < size-1; i++)
- String str = new String();
- while((str = in.readLine()) != null)
- {
- Scanner scn = new Scanner(str);
- int one = scn.nextInt()-1;
- int two = scn.nextInt()-1;
- int three = scn.nextInt()-1;
- node cur1 = nodes.get(one);
- node cur2 = nodes.get(two);
- node cur3 = nodes.get(three);
- if(!cur1.getConnected().contains(cur2))
- cur1.getConnected().add(cur2);
- if(!cur1.getConnected().contains(cur3))
- cur1.getConnected().add(cur3);
- if(!cur2.getConnected().contains(cur1))
- cur2.getConnected().add(cur1);
- if(!cur2.getConnected().contains(cur3))
- cur2.getConnected().add(cur3);
- if(!cur3.getConnected().contains(cur2))
- cur3.getConnected().add(cur2);
- if(!cur3.getConnected().contains(cur1))
- cur3.getConnected().add(cur1);
- }
- return nodes;
- }
Add Comment
Please, Sign In to add comment