src/main/java/science/atlarge/graphalytics/giraph/algorithms/cdlp/CommonCommunityDetectionLPComputation.java
/**
	 * Chooses new label by finding the most frequent label and picking the lowest id amongst the most frequent.
	 */
Chooses new label by finding the most frequent label and picking the lowest id amongst the most frequent.
Chooses new label by finding the most frequent label and picking the lowest id amongst the most frequent .
private void determineLabel(Vertex<LongWritable, LongWritable, E> vertex,
			Iterable<LongWritable> incomingLabels) {
		labelOccurences.clear();
		labelOccurences.defaultReturnValue(0L);
		for (LongWritable incomingLabel : incomingLabels) {
			long label = incomingLabel.get();
			labelOccurences.put(label, labelOccurences.get(label) + 1);
		}
		long bestLabel = 0;
		long highestFrequency = 0;
		for (Long2LongMap.Entry labelFrequency : labelOccurences.long2LongEntrySet()) {
			long label = labelFrequency.getLongKey();
			long frequency = labelFrequency.getLongValue();
			if (frequency > highestFrequency || (frequency == highestFrequency && label < bestLabel)) {
				bestLabel = label;
				highestFrequency = frequency;
			}
		}
		vertex.getValue().set(bestLabel);
	}
private void determineLabel ( Vertex < LongWritable , LongWritable , E > vertex , Iterable < LongWritable > incomingLabels ) { labelOccurences . clear ( ) ; labelOccurences . defaultReturnValue ( 0L ) ; for ( LongWritable incomingLabel : incomingLabels ) { long label = incomingLabel . get ( ) ; labelOccurences . put ( label , labelOccurences . get ( label ) + 1 ) ; } long bestLabel = 0 ; long highestFrequency = 0 ; for ( Long2LongMap . Entry labelFrequency : labelOccurences . long2LongEntrySet ( ) ) { long label = labelFrequency . getLongKey ( ) ; long frequency = labelFrequency . getLongValue ( ) ; if ( frequency > highestFrequency || ( frequency == highestFrequency && label < bestLabel ) ) { bestLabel = label ; highestFrequency = frequency ; } } vertex . getValue ( ) . set ( bestLabel ) ; }
Chooses new label by finding the most frequent label and picking the lowest id amongst the most frequent.
Chooses new label by finding the most frequent label and picking the lowest id amongst the most frequent .
// Compute for each incoming label the aggregate and maximum scores // Find the label with the highest frequency score (primary key) and lowest id (secondary key) // Update the label of this vertex