Class KleinbergSmallWorldGenerator<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.generators.Lattice2DGenerator<V,E>
-
- edu.uci.ics.jung.algorithms.generators.random.KleinbergSmallWorldGenerator<V,E>
-
- All Implemented Interfaces:
GraphGenerator<V,E>
,org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Graph<V,E>>
public class KleinbergSmallWorldGenerator<V,E> extends Lattice2DGenerator<V,E>
Graph generator that produces a random graph with small world properties. The underlying model is an mxn (optionally toroidal) lattice. Each node u has four local connections, one to each of its neighbors, and in addition 1+ long range connections to some node v where v is chosen randomly according to probability proportional to d^-alpha where d is the lattice distance between u and v and alpha is the clustering exponent.- See Also:
- "Navigation in a small world J. Kleinberg, Nature 406(2000), 845."
-
-
Field Summary
-
Fields inherited from class edu.uci.ics.jung.algorithms.generators.Lattice2DGenerator
col_count, edge_factory, graph_factory, is_directed, is_toroidal, row_count, vertex_factory
-
-
Constructor Summary
Constructors Constructor Description KleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int latticeSize, double clusteringExponent)
CreatesKleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int row_count, int col_count, double clusteringExponent)
KleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int row_count, int col_count, double clusteringExponent, boolean isToroidal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description edu.uci.ics.jung.graph.Graph<V,E>
create()
Generates a random small world network according to the parameters givenint
getConnectionCount()
Returns the number of new 'small-world' connections to be made to each vertex.void
setConnectionCount(int num_connections)
Sets the number of new 'small-world' connections (outgoing edges) to be added to each vertex.void
setRandom(java.util.Random random)
Sets theRandom
instance used by this instance.void
setRandomSeed(long seed)
Sets the seed of the internal random number generator.-
Methods inherited from class edu.uci.ics.jung.algorithms.generators.Lattice2DGenerator
getCol, getGridEdgeCount, getIndex, getRow, getVertex, getVertex, mod
-
-
-
-
Constructor Detail
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int latticeSize, double clusteringExponent)
Creates- Parameters:
graph_factory
-vertex_factory
-edge_factory
-latticeSize
-clusteringExponent
-
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int row_count, int col_count, double clusteringExponent)
- Parameters:
graph_factory
-vertex_factory
-edge_factory
-row_count
-col_count
-clusteringExponent
-
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(org.apache.commons.collections4.Factory<? extends edu.uci.ics.jung.graph.Graph<V,E>> graph_factory, org.apache.commons.collections4.Factory<V> vertex_factory, org.apache.commons.collections4.Factory<E> edge_factory, int row_count, int col_count, double clusteringExponent, boolean isToroidal)
- Parameters:
graph_factory
-vertex_factory
-edge_factory
-row_count
-col_count
-clusteringExponent
-isToroidal
-
-
-
Method Detail
-
setRandom
public void setRandom(java.util.Random random)
Sets theRandom
instance used by this instance. Useful for unit testing.
-
setRandomSeed
public void setRandomSeed(long seed)
Sets the seed of the internal random number generator. May be used to provide repeatable experiments.
-
setConnectionCount
public void setConnectionCount(int num_connections)
Sets the number of new 'small-world' connections (outgoing edges) to be added to each vertex.
-
getConnectionCount
public int getConnectionCount()
Returns the number of new 'small-world' connections to be made to each vertex.
-
create
public edu.uci.ics.jung.graph.Graph<V,E> create()
Generates a random small world network according to the parameters given- Specified by:
create
in interfaceorg.apache.commons.collections4.Factory<V>
- Overrides:
create
in classLattice2DGenerator<V,E>
- Returns:
- a random small world graph
- See Also:
Factory.create()
-
-