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 * Interface for data structures that store out-edges for a vertex. 26 * 27 * @param <I> Vertex id 28 * @param <E> Edge value 29 */ 30 public interface OutEdges<I extends WritableComparable, E extends Writable> 31 extends Iterable<Edge<I, E>>, Writable { 32 /** 33 * Initialize the data structure and set the edges from an iterable. 34 * This method (or one of the two alternatives) must be called 35 * after instantiation, unless readFields() is called. 36 * Note: whether parallel edges are allowed or not depends on the 37 * implementation. 38 * 39 * @param edges Iterable of edges 40 */ 41 void initialize(Iterable<Edge<I, E>> edges); 42 43 /** 44 * Initialize the data structure with the specified initial capacity. 45 * This method (or one of the two alternatives) must be called 46 * after instantiation, unless readFields() is called. 47 * 48 * @param capacity Initial capacity 49 */ 50 void initialize(int capacity); 51 52 /** 53 * Initialize the data structure with the default initial capacity. 54 * This method (or one of the two alternatives) must be called 55 * after instantiation, unless readFields() is called. 56 * 57 */ 58 void initialize(); 59 60 /** 61 * Add an edge. 62 * Note: whether parallel edges are allowed or not depends on the 63 * implementation. 64 * 65 * @param edge Edge to add 66 */ 67 void add(Edge<I, E> edge); 68 69 /** 70 * Remove all edges to the given target vertex. 71 * Note: the implementation will vary depending on whether parallel edges 72 * are allowed or not. 73 * 74 * @param targetVertexId Target vertex id 75 */ 76 void remove(I targetVertexId); 77 78 /** 79 * Return the number of edges. 80 * 81 * @return Number of edges 82 */ 83 int size(); 84 }