1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.giraph.edge; 20 21 import org.apache.hadoop.io.Writable; 22 import org.apache.hadoop.io.WritableComparable; 23 24 /** 25 * A complete edge, the target vertex and the edge value. Can only be one 26 * edge with a destination vertex id per edge map. 27 * 28 * @param <I> Vertex index 29 * @param <E> Edge value 30 */ 31 @SuppressWarnings("rawtypes") 32 public class DefaultEdge<I extends WritableComparable, E extends Writable> 33 implements ReusableEdge<I, E> { 34 /** Target vertex id */ 35 private I targetVertexId = null; 36 /** Edge value */ 37 private E value = null; 38 39 /** 40 * Constructor for reflection 41 */ 42 public DefaultEdge() { } 43 44 /** 45 * Create the edge with final values. Don't call, use EdgeFactory instead. 46 * 47 * @param targetVertexId Desination vertex id. 48 * @param value Value of the edge. 49 */ 50 protected DefaultEdge(I targetVertexId, E value) { 51 this.targetVertexId = targetVertexId; 52 this.value = value; 53 } 54 55 @Override 56 public I getTargetVertexId() { 57 return targetVertexId; 58 } 59 60 @Override 61 public E getValue() { 62 return value; 63 } 64 65 @Override 66 public void setTargetVertexId(I targetVertexId) { 67 this.targetVertexId = targetVertexId; 68 } 69 70 @Override 71 public void setValue(E value) { 72 this.value = value; 73 } 74 75 @Override 76 public String toString() { 77 return "(targetVertexId = " + targetVertexId + ", " + 78 "value = " + value + ")"; 79 } 80 }