@@ -0,0 +1,2614 @@
+/*%0AThis code is adjusted according to%0Ahttp://mail-archives.apache.org/mod_mbox/giraph-user/201403.mbox/%0A%253CCAHfPGSkkj=x8wTj=o0Sx2EiYcG=-DaFvxCvWXnOZetjZH8uztQ@mail.gmail.com%253E%0A*/%0A%0Aimport org.apache.giraph.graph.BasicComputation;%0Aimport org.apache.giraph.conf.LongConfOption;%0Aimport org.apache.giraph.edge.Edge;%0Aimport org.apache.giraph.graph.Vertex;%0Aimport org.apache.hadoop.io.DoubleWritable;%0Aimport org.apache.hadoop.io.FloatWritable;%0Aimport org.apache.hadoop.io.LongWritable;%0Aimport org.apache.log4j.Logger;%0A%0Aimport java.io.IOException;%0A%0A%0Apublic class TriangleCounting extends BasicComputation%3C%0A    DoubleWritable, DoubleWritable, FloatWritable, DoubleWritable%3E %7B%0A%0A  /** Class logger */%0A  private static final Logger LOG =%0ALogger.getLogger(TriangleCounting2.class);%0A%0A  @Override%0A  public void compute(%0A      Vertex%3CDoubleWritable, DoubleWritable, FloatWritable%3E vertex,%0A      Iterable%3CDoubleWritable%3E messages) throws IOException %7B%0A%0A  /** First Superstep releases messages to vertexIds() whose value is%0Agreater than its value. Both VertexId and Message are double **/%0A  if (getSuperstep() == 0) %7B%0A    for (Edge%3CDoubleWritable, FloatWritable%3E edge: vertex.getEdges()) %7B%0A      if (edge.getTargetVertexId().compareTo(vertex.getId()) == 1) %7B%0A        sendMessage(edge.getTargetVertexId(), vertex.getId());%0A        if (LOG.isDebugEnabled()) %7B%0A          LOG.debug(%22Vertex %22 + vertex.getId() + %22 sent message %22 +%0Avertex.getId() + %22 to vertex %22 + edge.getTargetVertexId());%0A        %7D%0A      %7D%0A    %7D%0A  %7D%0A%0A  /** Second superstep releases messages to message.get() %3C vertex.getId()%0A%3C targetVertexId() **/%0A  if (getSuperstep() == 1) %7B%0A    for (DoubleWritable message: messages) %7B%0A        for (Edge%3CDoubleWritable, FloatWritable%3E edge: vertex.getEdges()) %7B%0A          if (edge.getTargetVertexId().compareTo(vertex.getId()) +%0Avertex.getId().compareTo(message) == 2) %7B%0A            sendMessage(edge.getTargetVertexId(), message);%0A            if (LOG.isDebugEnabled()) %7B%0A              LOG.debug(%22Vertex %22 + vertex.getId() + %22 sent message %22 +%0Amessage + %22 to vertex %22 + edge.getTargetVertexId());%0A            %7D%0A          %7D%0A        %7D%0A    %7D%0A  %7D%0A  /** Sends messages to all its neighbours, the messages it receives **/%0A  if (getSuperstep() == 2) %7B%0A    for (DoubleWritable message: messages) %7B%0A        sendMessageToAllEdges(vertex, message);%0A    %7D%0A  %7D%0A%0A  if (getSuperstep() == 3) %7B%0A      double Value = 0.0;%0A      for (DoubleWritable message: messages) %7B%0A          if (vertex.getId().equals(message)) %7B%0A              Value += 1.0;%0A          %7D%0A      %7D%0A      vertex.setValue(new DoubleWritable(Value));%0A  %7D%0A%0A  vertex.voteToHalt();%0A  %7D%0A%7D%0A

Create TriangleCounting.java