示例#1
0
 public boolean contains(Text vertexID) {
   for (Vertex<Text, DoubleWritable, SemiClusterMessage> v : this.semiClusterVertexList) {
     if (v.getVertexID().equals(vertexID)) {
       return true;
     }
   }
   return false;
 }
示例#2
0
文件: Vertex.java 项目: pkdevbox/hama
  @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);
  }
示例#3
0
 /**
  * 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;
 }
示例#4
0
  public void write(DataOutput out) throws IOException {
    if (this.semiClusterId == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      out.writeUTF(semiClusterId);
    }
    out.writeDouble(semiClusterScore);

    if (this.semiClusterVertexList == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      out.writeInt(semiClusterVertexList.size());
      for (Vertex<Text, DoubleWritable, SemiClusterMessage> v : semiClusterVertexList) {
        v.write(out);
      }
    }
    out.writeInt(semiClusterContainThis.size());
    for (SemiClusterDetails semiClusterContainThi : semiClusterContainThis)
      semiClusterContainThi.write(out);
  }