Coverage Report - org.apache.giraph.block_app.test_setup.graphs.Small2GraphInit
 
Classes in this File Line Coverage Branch Coverage Complexity
Small2GraphInit
0%
0/14
0%
0/2
1.25
 
 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  
 package org.apache.giraph.block_app.test_setup.graphs;
 19  
 
 20  
 import org.apache.giraph.block_app.test_setup.NumericTestGraph;
 21  
 import org.apache.giraph.block_app.test_setup.TestGraphModifier;
 22  
 import org.apache.giraph.function.Supplier;
 23  
 import org.apache.hadoop.io.Writable;
 24  
 import org.apache.hadoop.io.WritableComparable;
 25  
 
 26  
 
 27  
 /**
 28  
  * Create a network that looks like:
 29  
  *   1      5
 30  
  *  / \    / \    6
 31  
  * 0---2  3---4
 32  
  *
 33  
  * where 6 is disconnected from the rest of the network.
 34  
  *
 35  
  * @param <I> Vertex id type
 36  
  * @param <V> Vertex value type
 37  
  * @param <E> Edge value type
 38  
  */
 39  
 public class Small2GraphInit<I extends WritableComparable,
 40  
     V extends Writable, E extends Writable>
 41  
     implements TestGraphModifier<I, V, E> {
 42  
   private final Supplier<E> edgeSupplier;
 43  
 
 44  
   public Small2GraphInit() {
 45  0
     this(null);
 46  0
   }
 47  
 
 48  0
   public Small2GraphInit(Supplier<E> edgeSupplier) {
 49  0
     this.edgeSupplier = edgeSupplier;
 50  0
   }
 51  
 
 52  
   @Override
 53  
   public void modifyGraph(NumericTestGraph<I, V, E> graph) {
 54  0
     graph.addSymmetricEdge(0, 1, createEdgeValue());
 55  0
     graph.addSymmetricEdge(0, 2, createEdgeValue());
 56  0
     graph.addSymmetricEdge(1, 2, createEdgeValue());
 57  0
     graph.addSymmetricEdge(3, 4, createEdgeValue());
 58  0
     graph.addSymmetricEdge(3, 5, createEdgeValue());
 59  0
     graph.addSymmetricEdge(4, 5, createEdgeValue());
 60  
 
 61  0
     graph.addVertex(6);
 62  0
   }
 63  
 
 64  
   private E createEdgeValue() {
 65  0
     return edgeSupplier != null ? edgeSupplier.get() : null;
 66  
   }
 67  
 }
 68