V
 the graph vertex typeE
 the graph edge typepublic class WattsStrogatzGraphGenerator<V,E> extends Object implements GraphGenerator<V,E,V>
The generator is described in the paper: D. J. Watts and S. H. Strogatz. Collective dynamics of smallworld networks. Nature 393(6684):440442, 1998.
The following paragraph from the paper describes the construction.
"The generator starts with a ring of n vertices, each connected to its k nearest neighbors (k must be even). Then it chooses a vertex and the edge that connects it to its nearest neighbor in a clockwise sense. With probability p, it reconnects this edge to a vertex chosen uniformly at random over the entire ring with duplicate edges forbidden; otherwise it leaves the edge in place. The process is repeated by moving clockwise around the ring, considering each vertex in turn until one lap is completed. Next, it considers the edges that connect vertices to their secondnearest neighbors clockwise. As before, it randomly rewires each of these edges with probability p , and continues this process, circulating around the ring and proceeding outward to more distant neighbors after each lap, until each edge in the original lattice has been considered once. As there are nk/2 edges in the entire graph, the rewiring process stops after k/2 laps. For p = 0, the original ring is unchanged; as p increases, the graph becomes increasingly disordered until for p = 1, all edges are rewired randomly. For intermediate values of p, the graph is a smallworld network: highly clustered like a regular graph, yet with small characteristic path length, like a random graph."
The authors require n » k » ln(n) » 1 and specifically k » ln(n) guarantees that a random graph will be connected.
Through the constructor parameter the model can be slightly changed into adding shortcut edges instead of rewiring. This variation was proposed in the paper: M. E. J. Newman and D. J. Watts, Renormalization group analysis of the smallworld network model, Physics Letters A, 263, 341, 1999.
Constructor and Description 

WattsStrogatzGraphGenerator(int n,
int k,
double p)
Constructor

WattsStrogatzGraphGenerator(int n,
int k,
double p,
boolean addInsteadOfRewire,
Random rng)
Constructor

WattsStrogatzGraphGenerator(int n,
int k,
double p,
long seed)
Constructor

Modifier and Type  Method and Description 

void 
generateGraph(Graph<V,E> target,
VertexFactory<V> vertexFactory,
Map<String,V> resultMap)
Generates a smallworld graph based on the WattsStrogatz model.

public WattsStrogatzGraphGenerator(int n, int k, double p)
n
 the number of nodesk
 connect each node to its k nearest neighbors in a ringp
 the probability of rewiring each edgeIllegalArgumentException
 in case of invalid parameterspublic WattsStrogatzGraphGenerator(int n, int k, double p, long seed)
n
 the number of nodesk
 connect each node to its k nearest neighbors in a ringp
 the probability of rewiring each edgeseed
 seed for the random number generatorIllegalArgumentException
 in case of invalid parameterspublic WattsStrogatzGraphGenerator(int n, int k, double p, boolean addInsteadOfRewire, Random rng)
n
 the number of nodesk
 connect each node to its k nearest neighbors in a ringp
 the probability of rewiring each edgeaddInsteadOfRewire
 whether to add shortcut edges instead of rewiringrng
 the random number generator to useIllegalArgumentException
 in case of invalid parameterspublic void generateGraph(Graph<V,E> target, VertexFactory<V> vertexFactory, Map<String,V> resultMap)
generateGraph
in interface GraphGenerator<V,E,V>
target
 the target graphvertexFactory
 the vertex factoryresultMap
 not used by this generator, can be nullCopyright © 2017. All rights reserved.