Class BarabasiGenerator<U>

java.lang.Object
es.uam.eps.ir.relison.graph.generator.random.BarabasiGenerator<U>
Type Parameters:
U - Type of the users
All Implemented Interfaces:
GraphGenerator<U>

public class BarabasiGenerator<U>
extends java.lang.Object
implements GraphGenerator<U>
Generator for graphs following the Barabasi-Albert Preferential Attachment model for graphs.

Reference: A-L. Barabási, R. Albert. Emergence of Scaling in Random Networks. Science 286(5439), pp. 509-512 (1999)

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private boolean configured
    Indicates if the generator is configured or not
    private boolean directed
    Indicates if the graph is directed or not
    private Generator<U> generator
    User generator.
    private int initialNodes
    Number of initial nodes
    private int numEdgesIter
    Number of new edges created each iteration.
    private int numIter
    Number of iterations
  • Constructor Summary

    Constructors 
    Constructor Description
    BarabasiGenerator()  
  • Method Summary

    Modifier and Type Method Description
    void configure​(boolean directed, int initialNodes, int numIter, int numEdgesIter, Generator<U> generator)
    Configures the graph.
    void configure​(java.lang.Object... configuration)
    Configures the generator.
    Graph<U> generate()
    Generates the graph.

    Methods inherited from class java.lang.Object

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

    • configured

      private boolean configured
      Indicates if the generator is configured or not
    • directed

      private boolean directed
      Indicates if the graph is directed or not
    • initialNodes

      private int initialNodes
      Number of initial nodes
    • numIter

      private int numIter
      Number of iterations
    • numEdgesIter

      private int numEdgesIter
      Number of new edges created each iteration.
    • generator

      private Generator<U> generator
      User generator.
  • 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 initialNodes, int numIter, int numEdgesIter, Generator<U> generator)
      Configures the graph.
      Parameters:
      directed - Indicates if the node is directed or not.
      initialNodes - Number of initial nodes of the graph.
      numIter - Number of iterations of the algorithm.
      numEdgesIter - Number of new edges to add each iteration
      generator - Object that automatically creates the indicated number of nodes.
    • generate

      Generates the graph.
      Specified by:
      generate in interface GraphGenerator<U>
      Returns:
      A Barabasi-Albert model graph if everything OK.
      Throws:
      GeneratorNotConfiguredException - if the generator is not configured
      GeneratorBadConfiguredException - if the generator is badly configured. In this case, if the number of edges per iteration is greater than the number of initial nodes.