kokx/tue-2io21

Huge code refactorings :D.

1 parent c04fc72 commit af5f4e3a1dbb09e4a6c3bcbf83f7835c4b16211b committed May 22, 2012
Showing with 33 additions and 115 deletions.
1. +19 −94 algorithm/Algorithm.java
2. +0 −5 algorithm/DeLiClu.java
3. +10 −14 algorithm/Optics.java
4. +4 −2 cluster
 @@ -13,12 +13,19 @@ protected Field field; /** + * Reachability plot + */ + ArrayList reachabilityPlot; + + /** * Constructor. */ public Algorithm() { } + // abstract methods + /** * Find the parameters * @@ -29,6 +36,13 @@ public Algorithm() public abstract void findParameters(int ci, int cj, int n); /** + * Run the algorithm. + */ + public abstract void run(); + + // implemented methods + + /** * Set the field. * * @param field Field @@ -39,67 +53,21 @@ public void setField(Field field) } /** - * Run the algorithm. - */ - public abstract void run(); - - /** * Cluster the data. */ - public void cluster(ArrayList reachabilityPlot) + public void cluster() { - /* - // TODO: Define L - - // create the root node - Node root = new Node(reachabilityPlot.get(0), null, L); - */ + // TODO: Implement } /** * Print reachability distances. */ - public abstract void printReachability(); - - /** - * Cluster the tree. - */ - public void cluster_tree(Node N, Node parent, PriorityQueue L) + public void printReachability() { - /* - if (null == L || L.size() == 0) { - // parent_of_N is a leaf - return; - } - - // take the next largest local maximum as possible separation between clusters - N.split_point = s = L.poll(); - - N1_points = null; // TODO: all points left of s (from N.points) - N2_points = null; // TODO: all points right of s (from N.points) - L1 = null; // TODO: all local maxima left of s (from L) - L2 = null; // TODO: all local maxima right of s (from L) - // TODO: NodeList NL = [(N1, L1), (N2, L2)] - - if ((average reachability value in any node in NL) / s.r_dist > 0.75) { - // s is not significant - cluster_tree(N, parent, L); - } else { - // remove clusters that are too small - if (N1.points.size() < min_cluster_size) NL.remove(N1, L1); - if (N2.points.size() < min_cluster_size) NL.remove(N1, L1); - if (NL.size() < 10) return; // now parent is a leaf - - if (s.reachability_distance and parent_of_N.split_point.reachability_distance are approximately the same) { - // let parent point to all nodes in NL instead of N - } else { - // let N point to all nodes in NL - } - for ((N_i, L_i) in NL) { - cluster_tree(N_i, parent, L_i); - } + for (AlgorithmPoint p : reachabilityPlot) { + System.out.println(p.getCluster() + " " + p.getReachabilityDistance()); } - */ } /** @@ -185,47 +153,4 @@ public long getKey() } } - /** - * Tree - */ - class Node - { - - Node parent; - - /** - * Children. - */ - ArrayList> children; - - /** - * The actual data. - */ - T data; - - public Node(T data) - { - this(data, null); - } - - public Node(T data, Node parent) - { - this.parent = parent; - this.data = data; - children = new ArrayList>(); - } - - public Node getParent() - { - return parent; - } - - /** - * Create a child. - */ - public void createChild(T c) - { - children.add(new Node(c, this)); - } - } }
 @@ -28,11 +28,6 @@ public void findParameters(int ci, int cj, int n) // TODO: Implement this } - public void printReachability() - { - // TODO: Implement this - } - public void run() { // TODO: Implement this
 @@ -29,11 +29,6 @@ ArrayList points; /** - * Reachability plot - */ - ArrayList reachabilityPlot; - - /** * Parameters. */ double epsilon; @@ -80,7 +75,6 @@ public void findParameters(int ci, int cj, int n) } } - @SuppressWarnings({"unchecked"}) public void run() { points = new ArrayList(); @@ -110,7 +104,16 @@ public void run() clusterId--; - // clusterId should now be the number of clusters + cluster(); + } + + /** + * TODO: Create a general method for this in Algorithm and use it. + */ + @SuppressWarnings({"unchecked"}) + public void cluster() + { + // clusterId is the number of clusters ArrayList clusters[] = (ArrayList[]) Array.newInstance(ArrayList.class, clusterId); for (int i = 0; i < clusterId; i++) { clusters[i] = new ArrayList(); @@ -154,13 +157,6 @@ public void run() } } - public void printReachability() - { - for (AlgorithmPoint p : reachabilityPlot) { - System.out.println(p.getCluster() + " " + p.getReachabilityDistance()); - } - } - void expandClusterOrder(AlgorithmPoint p) { Pair>, List>> nn = getNeighbours(p);
 @@ -19,7 +19,9 @@ message() { compile() { echo "Compiling............." - javac Main.java algorithm/*.java generator/*.java model/*.java quality/*.java visualize/*.java reachability/*.java + # first we remove all *.class files + rm -r *.class 2> /dev/null + javac -Xlint:unchecked Main.java algorithm/*.java generator/*.java model/*.java quality/*.java visualize/*.java reachability/*.java } run() @@ -98,6 +100,6 @@ else # run and plot reachability if [ "\$r" = "t" ]; then run_file \$file -r | java reachability.Main + xdg-open reach.png fi - xdg-open reach.png fi