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 double
beta
Rewiring probabilityprivate boolean
configured
Indicates if the generator is configuredprivate boolean
directed
Indicates if the graph is directedprivate Generator<U>
generator
Node generatorprivate int
meanDegree
Average degree of the graph.private int
numNodes
Indicates the number of nodes of the generated graph.private Graph<U>
ring
Original ring graph. -
Constructor Summary
Constructors Constructor Description WattsStrogatzGenerator()
-
Method Summary
Modifier and Type Method Description void
configure(boolean directed, int numNodes, int meanDegree, double beta, Generator<U> generator)
Configures the graph generator.void
configure(java.lang.Object... configuration)
Configures the generator.Graph<U>
generate()
Generates a graph.private void
rewire(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:GraphGenerator
Configures the generator.- Specified by:
configure
in 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:GraphGenerator
Generates a graph.- Specified by:
generate
in 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.
-