-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathIClusterCollection.java
77 lines (61 loc) · 1.64 KB
/
IClusterCollection.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
76
77
package phylonet.coalescent;
import java.util.Set;
import phylonet.tree.model.sti.STITreeCluster.Vertex;
/***
* Contains a set of clusters (used to implement X in ASTRAL/DynaDup).
* @author smirarab
*
*/
public interface IClusterCollection {
/**
* Every cluster in the clustercollection is a subset
* of the top cluster (by construction).
* @return
*/
Vertex getTopVertex();
int getClusterCount();
boolean addCluster(Vertex nv, int size);
boolean removeCluster(Vertex nv, int size);
boolean contains(Vertex reverse);
/**
* Returns a new IClusterCollection where the top node is v
* @param v
* @return
*/
IClusterCollection getContainedClusters(Vertex v);
/**
* Returns all ways of dividing the top cluster into two subsets
* such that the two subsets are both part of this IClusterColleciton
* @return
*/
Iterable<VertexPair> getClusterResolutions();
/**
* Returns a collection of sets of clusters contained in
* this IClusterCollection, sorted by size from ? to ?
* @return
*/
Iterable<Set<Vertex>> getSubClusters();
/***
* Returns the subclusters of a certain size.
* @param size
* @return
*/
Set<Vertex> getSubClusters(int size);
class VertexPair implements Comparable<VertexPair> {
public final Vertex cluster1;
public final Vertex cluster2;
public final Vertex both;
public double weight = 0, upperbound = 0;
public VertexPair(Vertex c1, Vertex c2, Vertex b) {
cluster1 = c1;
cluster2 = c2;
both = b;
}
@Override
public int compareTo(VertexPair o) {
if (upperbound > o.upperbound) return -1;
if (upperbound == o.upperbound) return 0;
return 1;
}
}
}