Exemple #1
0
  @Override
  public void addVertex(V vertexID, List<Edge<V, E>> edges, M value) throws IOException {
    MapWritable msg = new MapWritable();
    // Create the new vertex.
    Vertex<V, E, M> vertex = GraphJobRunner.<V, E, M>newVertexInstance(GraphJobRunner.VERTEX_CLASS);
    vertex.setEdges(edges);
    vertex.setValue(value);
    vertex.setVertexID(vertexID);

    msg.put(GraphJobRunner.FLAG_VERTEX_INCREASE, vertex);
    runner.getPeer().send(runner.getHostName(vertexID), new GraphJobMessage(msg));

    alterVertexCounter(1);
  }
 /**
  * The text file essentially should look like: <br>
  * VERTEX_ID\t(n-tab separated VERTEX_ID:VERTEX_VALUE pairs)<br>
  * E.G:<br>
  * 1\t2:25\t3:32\t4:21<br>
  * 2\t3:222\t1:922<br>
  * etc.
  */
 @Override
 public boolean parseVertex(
     LongWritable key, Text value, Vertex<IntWritable, IntWritable, IntIntPairWritable> vertex) {
   String[] split = value.toString().split("\t");
   for (int i = 0; i < split.length; i++) {
     if (i == 0) {
       vertex.setVertexID(new IntWritable(Integer.parseInt(split[i])));
     } else {
       String[] split2 = split[i].split(":");
       vertex.addEdge(
           new Edge<>(
               new IntWritable(Integer.parseInt(split2[0])),
               new IntWritable(Integer.parseInt(split2[1]))));
     }
   }
   return true;
 }