src/twitter/io/Input.java
/*
	 * Read network file in this format
	 * 
	 * ;vicegandako;sharon_cuneta12;RafaelRosell;
	 * vicegandako;0;1.0;1.0;1.0
	 * sharon_cuneta12;0;0;0;0
	 * ...
	 */
Read network file in this format


Read network file in this format
public static HashMap<Long,HashSet<Long>> readNetworkCSVWeighted(TwitterRetry twitter, String netFile) throws IOException, TwitterException{
		HashMap<Long,HashSet<Long>> ret = new HashMap<Long,HashSet<Long>>();
		BufferedReader reader = new BufferedReader(new FileReader(netFile));
		String line = null;
		line = reader.readLine();
		String [] usersArray = line.substring(1).split(";"); 
		ResponseList<User> users = null;
		if (usersArray.length > 100) {
			int lastIdx = 0;
			for (int i = 0; i < usersArray.length; i += 100) {
				String [] subArray = Arrays.copyOfRange(usersArray, i, i+100);
				ResponseList<User> users2 = twitter.lookupUsers(subArray);
				System.out.println("input: "+subArray.length + " | output: "+users2.size());
				if (users == null) users = users2;
				else users.addAll(users2);
				lastIdx = i;
			}
			String [] rest = Arrays.copyOfRange(usersArray, lastIdx, usersArray.length);
			ResponseList<User> users2 = twitter.lookupUsers(rest);
			users.addAll(users2);
			System.out.println("input: "+rest.length + " | output: "+users2.size());
		} else users = twitter.lookupUsers(usersArray);
		line = reader.readLine();
		while (line != null) {
			String [] lineArray = line.split(";");
			User u = getUserByScreename(users, lineArray[0]);
			if (u == null) {
				System.err.println("User not found: "+lineArray[0] +" - SKIPPING");
				line = reader.readLine();
				continue;
			}
			HashSet<Long> links = new HashSet<Long>();
			for (int i = 1; i < lineArray.length; i++) {
				if (!lineArray[i].equals("0")) {
					User u2 = getUserByScreename(users, usersArray[i-1]);
					if (u2 == null) {
						System.err.println("User not found: "+usersArray[i-1] +" - SKIPPING");
						continue;
					}
					links.add(u2.getId());
				}
			}
			ret.put(u.getId(), links);
			line = reader.readLine();
		}
		return ret;
	}
public static HashMap < Long , HashSet < Long > > readNetworkCSVWeighted ( TwitterRetry twitter , String netFile ) throws IOException , TwitterException { HashMap < Long , HashSet < Long > > ret = new HashMap < Long , HashSet < Long > > ( ) ; BufferedReader reader = new BufferedReader ( new FileReader ( netFile ) ) ; String line = null ; line = reader . readLine ( ) ; String [ ] usersArray = line . substring ( 1 ) . split ( ";" ) ; ResponseList < User > users = null ; if ( usersArray . length > 100 ) { int lastIdx = 0 ; for ( int i = 0 ; i < usersArray . length ; i += 100 ) { String [ ] subArray = Arrays . copyOfRange ( usersArray , i , i + 100 ) ; ResponseList < User > users2 = twitter . lookupUsers ( subArray ) ; System . out . println ( "input: " + subArray . length + " | output: " + users2 . size ( ) ) ; if ( users == null ) users = users2 ; else users . addAll ( users2 ) ; lastIdx = i ; } String [ ] rest = Arrays . copyOfRange ( usersArray , lastIdx , usersArray . length ) ; ResponseList < User > users2 = twitter . lookupUsers ( rest ) ; users . addAll ( users2 ) ; System . out . println ( "input: " + rest . length + " | output: " + users2 . size ( ) ) ; } else users = twitter . lookupUsers ( usersArray ) ; line = reader . readLine ( ) ; while ( line != null ) { String [ ] lineArray = line . split ( ";" ) ; User u = getUserByScreename ( users , lineArray [ 0 ] ) ; if ( u == null ) { System . err . println ( "User not found: " + lineArray [ 0 ] + " - SKIPPING" ) ; line = reader . readLine ( ) ; continue ; } HashSet < Long > links = new HashSet < Long > ( ) ; for ( int i = 1 ; i < lineArray . length ; i ++ ) { if ( ! lineArray [ i ] . equals ( "0" ) ) { User u2 = getUserByScreename ( users , usersArray [ i - 1 ] ) ; if ( u2 == null ) { System . err . println ( "User not found: " + usersArray [ i - 1 ] + " - SKIPPING" ) ; continue ; } links . add ( u2 . getId ( ) ) ; } } ret . put ( u . getId ( ) , links ) ; line = reader . readLine ( ) ; } return ret ; }
Read network file in this format
Read network file in this format
// read input file line by line
 // skips the first ;
 // gets user
 // gets his connections
