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 probability
    private boolean configured
    Indicates if the generator is configured
    private boolean directed
    Indicates if the graph is directed
    private Generator<U> generator
    Node generator
    private 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • directed

      private boolean directed
      Indicates if the graph is directed
    • numNodes

      private int numNodes
      Indicates the number of nodes of the generated graph.
    • meanDegree

      private int meanDegree
      Average degree of the graph.
    • beta

      private double beta
      Rewiring probability
    • generator

      private Generator<U> generator
      Node generator
    • configured

      private boolean configured
      Indicates if the generator is configured
    • ring

      private Graph<U> ring
      Original ring graph.
  • Constructor Details

  • Method Details

    • configure

      public void configure​(java.lang.Object... configuration)
      Description copied from interface: GraphGenerator
      Configures the generator.
      Specified by:
      configure in interface GraphGenerator<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 interface GraphGenerator<U>
      Returns:
      the generated graph.
      Throws:
      GeneratorNotConfiguredException - The generator is not configured.
      GeneratorBadConfiguredException - The generator parameters are incorretct.
    • rewire

      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.
      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 node
      adj - the current destination node.