static <E extends WeightedEdge> int
getMaxClassWeighted(int v, int[] vertexAssignments,
WeightedGraph<E> g) {
Set<E> edges = g.getAdjacencyList(v);
TIntDoubleMap classSums = new TIntDoubleHashMap();
for (WeightedEdge e : edges) {
int n = (e.to() == v) ? e.from() : e.to();
int nClass = vertexAssignments[n];
double weight = e.weight();
if (classSums.containsKey(nClass)) {
double curWeight = classSums.get(nClass);
classSums.put(nClass, weight + curWeight);
}
else {
classSums.put(nClass, weight);
}
}
double maxSum = -1d;
TIntSet ties = new TIntHashSet();
TIntDoubleIterator iter = classSums.iterator();
while (iter.hasNext()) {
iter.advance();
double weight = iter.value();
if (weight > maxSum) {
maxSum = weight;