giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Kumar <toga...@gmail.com>
Subject Running Triangle Count problem in giraph
Date Fri, 21 Mar 2014 14:08:48 GMT
Hi

i am working with giraph version1.0 and i have created a TriangleCounting
program based on some previous posts .My program runs with out any error
but it is not giving any relevant data .
for clarity i am attaching the program and the input used.





import org.apache.giraph.edge.Edge;
import org.apache.giraph.graph.Vertex;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.log4j.Logger;

import java.io.IOException;

@Algorithm(
    name = "Traingle Counting in Giraph",
    description = "Return the total number of triangle and also enumerates
traingles per vertex"
)
public class TriangleCounting extends Vertex<LongWritable,
DoubleWritable,FloatWritable, DoubleWritable> {

  /** Class logger */
  private static final Logger LOG =
Logger.getLogger(TriangleCounting.class);

  @Override
  public void compute(Iterable<DoubleWritable> messages) throws IOException
{

  /** First Superstep releases messages to vertexIds() whose value is
greater than its value. Both VertexId and Message are double **/
  if (getSuperstep() == 0) {
    for (Edge<LongWritable, FloatWritable> edge:getEdges()) {
      if (edge.getTargetVertexId().compareTo(getId()) == 1) {
      double d=getId().get();
        sendMessage(edge.getTargetVertexId(),new DoubleWritable(d));
        if (LOG.isDebugEnabled()) {
          LOG.debug("Vertex " + getId() + " sent message " + getId() + " to
vertex " + edge.getTargetVertexId());
        }
        System.out.println("Vertex " + getId() + " sent message " + getId()
+ " to vertex " + edge.getTargetVertexId());
      }
    }
  }

  /** Second superstep releases messages to message.get() < vertex.getId()
< targetVertexId() **/
  if (getSuperstep() == 1) {
    for (DoubleWritable message: messages) {
        for (Edge<LongWritable, FloatWritable> edge: getEdges()) {
        double etvid=edge.getTargetVertexId().compareTo(getId()) +
getId().get();
          if (new DoubleWritable(etvid).compareTo(message) == 2) {
            sendMessage(edge.getTargetVertexId(), message);
            if (LOG.isDebugEnabled()) {
              LOG.debug("Vertex " + getId() + " sent message " + message +
" to vertex " + edge.getTargetVertexId());
            }
            System.out.println("Vertex " + getId() + " sent message " +
message + " to vertex " + edge.getTargetVertexId());
          }
        }
    }
  }
  /** Sends messages to all its neighbours, the messages it receives **/
  if (getSuperstep() == 2) {
    for (DoubleWritable message: messages) {
        sendMessageToAllEdges(message);
    }
  }

  if (getSuperstep() == 3) {
      double Value = 0.0;
      for (DoubleWritable message: messages) {
          if (getId().equals(message)) {
              Value += 1.0;
              System.out.println("Vertex " + getId() + " received message "
+ message);
          }
      }
      setValue(new DoubleWritable(Value));
  }

  voteToHalt();
  }
}

Mime
View raw message