-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToClusterMap.java
59 lines (45 loc) · 1.21 KB
/
ToClusterMap.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.io.* ;
class ToClusterMap{
int powk ;
int cluster ;
public void go(String input){
try{
BufferedReader buf = new BufferedReader( new FileReader(input) ) ;
String s = buf.readLine() ;
String[] tmps = s.split(" ");
cluster = Integer.valueOf(tmps[0]);
powk = Integer.valueOf(tmps[1]) ;
// System.out.println("powk:"+powk+" clsuter:"+cluster) ;
buf.close() ;
//for each cluster
for(int i=0 ; i<cluster ; i++){
System.err.println("cluster:"+i) ;
BufferedReader b = new BufferedReader( new FileReader(input) ) ;
String t = b.readLine() ;
while( (t=b.readLine())!=null ){
String[] tmp = t.split("\t") ;
String node = tmp[0] ;
String array_string = tmp[1] ;
System.out.print(node) ;
System.out.print(":") ;
String[] array = array_string.split(" ") ;
int base = i*powk ;
for(int k=0 ; k<powk ; k++){
int index = base+k ;
System.out.print(array[index]+" ") ;
}
System.out.print("\t") ;
}
b.close() ;
System.out.print("\n") ;
}
}
catch(IOException e){
e.printStackTrace() ;
}
}
public static void main(String[] args){
ToClusterMap c = new ToClusterMap();
c.go(args[0]) ;
}
}