try {
int ID = 0;
if (values.size() <= 0) {
System.err.println("Reduce Input Error!");
throw new TwisterException("Reduce input error no values.");
}
for (Value value : values) {
BytesValue val = (BytesValue) value;
Node node = new Node(val.getBytes());
ID = node.getID();
// save only the minimum distance for each edge
for (int v : node.getEdges().keySet()) {
if (node.getEdgeWeight(v) < edgeWeights.get(v))
edgeWeights.put(v, node.getEdgeWeight(v));
}
}
// create the new node with non-redundant edges and edge with minimum
// distance and emit it
Node n = new Node(ID);
for (int i = 1; i <= 1000; i++) {
if (edgeWeights.get(i) != Integer.MAX_VALUE)
n.setEdgeWeight(i, edgeWeights.get(i));
}
collector.collect(new StringKey("" + n.getID()), new BytesValue(n
.getBytes()));
} catch (SerializationException e) {
e.printStackTrace();
throw new TwisterException(e);
}
}