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:
com.google.common.base.Supplier<Graph<V,
,E>> GraphGenerator<V,
,E> Supplier<Graph<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:
-
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionKleinbergSmallWorldGenerator
(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int latticeSize, double clusteringExponent) Creates an instance with the specified parameters, whose underlying lattice is (a) of sizelatticeSize
xlatticeSize
, and (b) toroidal.KleinbergSmallWorldGenerator
(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int row_count, int col_count, double clusteringExponent) Creates an instance with the specified parameters, whose underlying lattice is toroidal.KleinbergSmallWorldGenerator
(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int row_count, int col_count, double clusteringExponent, boolean isToroidal) Creates an instance with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionget()
Generates a random small world network according to the parameters givenint
private void
void
setConnectionCount
(int num_connections) Sets the number of new 'small-world' connections (outgoing edges) to be added to each vertex.void
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
-
Field Details
-
clustering_exponent
private double clustering_exponent -
random
-
num_connections
private int num_connections
-
-
Constructor Details
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int latticeSize, double clusteringExponent) Creates an instance with the specified parameters, whose underlying lattice is (a) of sizelatticeSize
xlatticeSize
, and (b) toroidal.- Parameters:
graphFactory
- factory for graphs of the appropriate typevertexFactory
- factory for vertices of the appropriate typeedgeFactory
- factory for edges of the appropriate typelatticeSize
- the number of rows and columns of the underlying latticeclusteringExponent
- the clustering exponent
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int row_count, int col_count, double clusteringExponent) Creates an instance with the specified parameters, whose underlying lattice is toroidal.- Parameters:
graphFactory
- factory for graphs of the appropriate typevertexFactory
- factory for vertices of the appropriate typeedgeFactory
- factory for edges of the appropriate typerow_count
- number of rows of the underlying latticecol_count
- number of columns of the underlying latticeclusteringExponent
- the clustering exponent
-
KleinbergSmallWorldGenerator
public KleinbergSmallWorldGenerator(com.google.common.base.Supplier<? extends Graph<V, E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int row_count, int col_count, double clusteringExponent, boolean isToroidal) Creates an instance with the specified parameters.- Parameters:
graphFactory
- factory for graphs of the appropriate typevertexFactory
- factory for vertices of the appropriate typeedgeFactory
- factory for edges of the appropriate typerow_count
- number of rows of the underlying latticecol_count
- number of columns of the underlying latticeclusteringExponent
- the clustering exponentisToroidal
- whether the underlying lattice is toroidal
-
-
Method Details
-
initialize
private void initialize() -
setRandom
Sets theRandom
instance used by this instance. Useful for unit testing.- Parameters:
random
- theRandom
instance for this class to use
-
setRandomSeed
public void setRandomSeed(long seed) Sets the seed of the internal random number generator. May be used to provide repeatable experiments.- Parameters:
seed
- the random seed that this class's random number generator is to use
-
setConnectionCount
public void setConnectionCount(int num_connections) Sets the number of new 'small-world' connections (outgoing edges) to be added to each vertex.- Parameters:
num_connections
- the number of outgoing small-world edges to add to each vertex
-
getConnectionCount
public int getConnectionCount()- Returns:
- the number of new 'small-world' connections that will originate at each vertex
-
get
Generates a random small world network according to the parameters given
-