Class WattsStrogatzGenerator<U>
java.lang.Object
es.uam.eps.ir.relison.graph.generator.random.WattsStrogatzGenerator<U>
- Type Parameters:
U- Type of the vertices.
- All Implemented Interfaces:
GraphGenerator<U>
public class WattsStrogatzGenerator<U> extends java.lang.Object implements GraphGenerator<U>
Generator for random graphs using the Watts-Strogatz model.
Reference: D.J. Watts, S.H. Strogatz. Collective dynamics of 'small-world' networks. Nature 393(6684), pp. 440-442 (1998)
-
Field Summary
Fields Modifier and Type Field Description private doublebetaRewiring probabilityprivate booleanconfiguredIndicates if the generator is configuredprivate booleandirectedIndicates if the graph is directedprivate Generator<U>generatorNode generatorprivate intmeanDegreeAverage degree of the graph.private intnumNodesIndicates the number of nodes of the generated graph.private Graph<U>ringOriginal ring graph. -
Constructor Summary
Constructors Constructor Description WattsStrogatzGenerator() -
Method Summary
Modifier and Type Method Description voidconfigure(boolean directed, int numNodes, int meanDegree, double beta, Generator<U> generator)Configures the graph generator.voidconfigure(java.lang.Object... configuration)Configures the generator.Graph<U>generate()Generates a graph.private voidrewire(Graph<U> graph, java.util.List<U> list, java.util.Random rng, U node, U adj)Rewires a connection in a graph.
-
Field Details
-
directed
private boolean directedIndicates if the graph is directed -
numNodes
private int numNodesIndicates the number of nodes of the generated graph. -
meanDegree
private int meanDegreeAverage degree of the graph. -
beta
private double betaRewiring probability -
generator
Node generator -
configured
private boolean configuredIndicates if the generator is configured -
ring
Original ring graph.
-
-
Constructor Details
-
WattsStrogatzGenerator
public WattsStrogatzGenerator()
-
-
Method Details
-
configure
public void configure(java.lang.Object... configuration)Description copied from interface:GraphGeneratorConfigures the generator.- Specified by:
configurein interfaceGraphGenerator<U>- Parameters:
configuration- An array containing the configuration parameters.
-
configure
public void configure(boolean directed, int numNodes, int meanDegree, double beta, Generator<U> generator)Configures the graph generator.- Parameters:
directed- Indicates if the graph is directed.numNodes- Number of nodes of the graph.meanDegree- Average degree of the nodes.beta- Rewiring probability (between 0 and 1).generator- Node generator.
-
generate
Description copied from interface:GraphGeneratorGenerates a graph.- Specified by:
generatein interfaceGraphGenerator<U>- Returns:
- the generated graph.
- Throws:
GeneratorNotConfiguredException- The generator is not configured.GeneratorBadConfiguredException- The generator parameters are incorretct.
-
rewire
Rewires a connection in a graph.- Parameters:
graph- the graph.list- the list of nodes in the graph.rng- the random number generator to determine whether we have to rewire or not.node- the origin nodeadj- the current destination node.
-