-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClust.java
75 lines (58 loc) · 1.86 KB
/
Clust.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !! Author: Nikos Koulouris !!
// !! Email: [email protected] !!
// !! Date 15/10/2014 !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
public class Clust {
static int n1=0;
static int n2=0;
static int n3=0;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !! Change to file destination of input file !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
static String fileDestination = "C:\\Users\\workspace\\test1.txt";
public static void main(String[] args) throws IOException {
int result = 0;
float Q;
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(fileDestination));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//precalaculate n1, n2, n3
precalculate(reader);
reader.close();
//reread file
reader = new BufferedReader(new FileReader(fileDestination));
Graph T = new Graph(reader, n1, n2, n3);
do {
T.updateLabels();
} while(T.buildReducedGraphAdnContinue());
System.out.println("Final Labels:");
T.printlabels();
}
private static void precalculate(BufferedReader r) throws IOException {
//does all the precalculations, counting nodes in each partite
String line = null;
line = r.readLine();
HashSet part1 = new HashSet();
HashSet part2 = new HashSet();
HashSet part3 = new HashSet();
while ((line = r.readLine()) != null) {
String[] parts = line.split("\\t");
part1.add(parts[0]);
part2.add(parts[1]);
part3.add(parts[2]);
}
n1 = part1.size();
n2 = part2.size();
n3 = part3.size();
}
}