View Javadoc
1   package edu.uci.ics.jung.algorithms.generators.random;
2   
3   
4   import junit.framework.Assert;
5   import edu.uci.ics.jung.algorithms.generators.Lattice2DGenerator;
6   import edu.uci.ics.jung.algorithms.generators.TestLattice2D;
7   import edu.uci.ics.jung.graph.Graph;
8   
9   
10  /**
11   * 
12   * @author Joshua O'Madadhain
13   */
14  public class TestKleinberg extends TestLattice2D {
15  	
16      @Override
17      protected Lattice2DGenerator<String, Number> generate(int i, int j, int k)
18      {
19          return new KleinbergSmallWorldGenerator<String,Number>(
20                  k == 0 ? undirectedGraphFactory : directedGraphFactory, 
21                  vertexFactory, edgeFactory,
22                  i, // rows
23                  i, // columns
24                  0.1, // clustering exponent
25                  j == 0 ? true : false); // toroidal?
26      }
27      
28      @Override
29      protected void checkEdgeCount(Lattice2DGenerator<String, Number> generator,
30      	Graph<String, Number> graph) 
31      
32      {
33          Assert.assertEquals(
34          	generator.getGridEdgeCount() +
35                  ((KleinbergSmallWorldGenerator<?, ?>)generator).getConnectionCount()
36                  	* graph.getVertexCount(), 
37              graph.getEdgeCount());
38      }
39  }