Class DirectedScaleFreeGraphGenerator<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    GraphGenerator<V,​E,​V>

    public class DirectedScaleFreeGraphGenerator<V,​E>
    extends Object
    implements GraphGenerator<V,​E,​V>
    A generator for directed scale-free graphs.

    This generator creates a directed scale-free graph according to a power law, as described in Bollobás et al. The paper can be cited as Béla Bollobás, Christian Borgs, Jennifer Chayes, and Oliver Riordan. "Directed scale-free graphs." Proceedings of the fourteenth annual ACM-SIAM symposium on Discrete algorithms. Society for Industrial and Applied Mathematics, 2003.

    In This generator, the graph continues to grow one edge per step, according to the probabilities alpha, beta, and gamma (which sum up to 1).

    • alpha is the probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
    • beta is the probability that the new edge is from an existing vertex v to an existing vertex w, where v and w are chosen independently, v according to d_out + delta_out, and w according to d_in + delta_in.
    • gamma is the probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.

    In their original paper, the graph continues to grow according to a certain power law until a certain number of edges is reached irrespective to the number of nodes.
    However, because the target number of edges is not known beforehand, in this implementation, we added another feature that enables the user to grow the curve according to that power law until the target number of edges or target number of nodes is reached.

    Author:
    Amr ALHOSSARY
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectedScaleFreeGraphGenerator​(float alpha, float gamma, float deltaIn, float deltaOut, int targetEdges, int targetNodes)
      Constructs a Generator.
      DirectedScaleFreeGraphGenerator​(float alpha, float gamma, float deltaIn, float deltaOut, int targetEdges, int targetNodes, long seed)
      Constructs a Generator using a seed for the random number generator.
      DirectedScaleFreeGraphGenerator​(float alpha, float gamma, float deltaIn, float deltaOut, int targetEdges, int targetNodes, long seed, boolean allowingMultipleEdges, boolean allowingSelfLoops)
      Constructs a Generator using a seed for the random number generator and sets the two relaxation options allowingMultipleEdges and allowingSelfLoops.
      DirectedScaleFreeGraphGenerator​(float alpha, float gamma, float deltaIn, float deltaOut, int targetEdges, int targetNodes, Random rng)
      Construct a new generator using the provided random number generator.
      DirectedScaleFreeGraphGenerator​(float alpha, float gamma, float deltaIn, float deltaOut, int targetEdges, int targetNodes, Random rng, boolean allowingMultipleEdges, boolean allowingSelfLoops)
      Construct a new generator using the provided random number generator and sets the two relaxation options allowingMultipleEdges and allowingSelfLoops.
    • Constructor Detail

      • DirectedScaleFreeGraphGenerator

        public DirectedScaleFreeGraphGenerator​(float alpha,
                                               float gamma,
                                               float deltaIn,
                                               float deltaOut,
                                               int targetEdges,
                                               int targetNodes)
        Constructs a Generator.
        Parameters:
        alpha - The probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
        gamma - The probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.
        deltaIn - The in-degree bias used for Alpha and Beta.
        deltaOut - The out-degree bias used for Beta and Gamma.
        targetEdges - Target total number of edges to reach. It has a higher priority than targetNodes. Zero is a valid value.
        If negative number, the user does not care about the total number of edges and is interested only in the number of nodes, therefore, targetNodes will be considered instead. Otherwise, targetEdges will be considered and targetEdges will be ignored.
        targetNodes - Target number of nodes to reach. Zero is a valid value.
        This parameter has lower priority than targetEdges and will be used only if targetEdges given is a negative number.
      • DirectedScaleFreeGraphGenerator

        public DirectedScaleFreeGraphGenerator​(float alpha,
                                               float gamma,
                                               float deltaIn,
                                               float deltaOut,
                                               int targetEdges,
                                               int targetNodes,
                                               long seed)
        Constructs a Generator using a seed for the random number generator.
        Parameters:
        alpha - The probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
        gamma - The probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.
        deltaIn - The in-degree bias used for Alpha and Beta.
        deltaOut - The out-degree bias used for Beta and Gamma.
        targetEdges - Target total number of edges to reach. It has a higher priority than targetNodes. Zero is a valid value.
        If negative number, the user does not care about the total number of edges and is interested only in the number of nodes, therefore, targetNodes will be considered instead. Otherwise, targetEdges will be considered and targetEdges will be ignored.
        targetNodes - Target number of nodes to reach. Zero is a valid value.
        This parameter has lower priority than targetEdges and will be used only if targetEdges given is a negative number.
        seed - The seed to feed to the random number generator.
      • DirectedScaleFreeGraphGenerator

        public DirectedScaleFreeGraphGenerator​(float alpha,
                                               float gamma,
                                               float deltaIn,
                                               float deltaOut,
                                               int targetEdges,
                                               int targetNodes,
                                               long seed,
                                               boolean allowingMultipleEdges,
                                               boolean allowingSelfLoops)
        Constructs a Generator using a seed for the random number generator and sets the two relaxation options allowingMultipleEdges and allowingSelfLoops.
        Parameters:
        alpha - The probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
        gamma - The probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.
        deltaIn - The in-degree bias used for Alpha and Beta.
        deltaOut - The out-degree bias used for Beta and Gamma.
        targetEdges - Target total number of edges to reach. It has a higher priority than targetNodes. Zero is a valid value.
        If negative number, the user does not care about the total number of edges and is interested only in the number of nodes, therefore, targetNodes will be considered instead. Otherwise, targetEdges will be considered and targetEdges will be ignored.
        targetNodes - Target number of nodes to reach. Zero is a valid value.
        This parameter has lower priority than targetEdges and will be used only if targetEdges given is a negative number.
        seed - The seed to feed to the random number generator.
        allowingMultipleEdges - whether the generator allows multiple parallel edges between the same two vertices (v, w).
        allowingSelfLoops - whether the generator allows self loops from the a vertex to itself.
      • DirectedScaleFreeGraphGenerator

        public DirectedScaleFreeGraphGenerator​(float alpha,
                                               float gamma,
                                               float deltaIn,
                                               float deltaOut,
                                               int targetEdges,
                                               int targetNodes,
                                               Random rng)
        Construct a new generator using the provided random number generator.
        Parameters:
        alpha - The probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
        gamma - The probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.
        deltaIn - The in-degree bias used for Alpha and Beta.
        deltaOut - The out-degree bias used for Beta and Gamma.
        targetEdges - Target total number of edges to reach. It has a higher priority than targetNodes. Zero is a valid value.
        If negative number, the user does not care about the total number of edges and is interested only in the number of nodes, therefore, targetNodes will be considered instead. Otherwise, targetEdges will be considered and targetEdges will be ignored.
        targetNodes - Target number of nodes to reach. Zero is a valid value.
        This parameter has lower priority than targetEdges and will be used only if targetEdges given is a negative number.
        rng - The Random object to use.
      • DirectedScaleFreeGraphGenerator

        public DirectedScaleFreeGraphGenerator​(float alpha,
                                               float gamma,
                                               float deltaIn,
                                               float deltaOut,
                                               int targetEdges,
                                               int targetNodes,
                                               Random rng,
                                               boolean allowingMultipleEdges,
                                               boolean allowingSelfLoops)
        Construct a new generator using the provided random number generator and sets the two relaxation options allowingMultipleEdges and allowingSelfLoops.
        Parameters:
        alpha - The probability that the new edge is from a new vertex v to an existing vertex w, where w is chosen according to d_in + delta_in.
        gamma - The probability that the new edge is from an existing vertex v to a new vertex w, where v is chosen according to d_out + delta_out.
        deltaIn - The in-degree bias used for Alpha and Beta.
        deltaOut - The out-degree bias used for Beta and Gamma.
        targetEdges - Target total number of edges to reach. It has a higher priority than targetNodes. Zero is a valid value.
        If negative number, the user does not care about the total number of edges and is interested only in the number of nodes, therefore, targetNodes will be considered instead. Otherwise, targetEdges will be considered and targetEdges will be ignored.
        targetNodes - Target number of nodes to reach. Zero is a valid value.
        This parameter has lower priority than targetEdges and will be used only if targetEdges given is a negative number.
        rng - The Random object to use.
        allowingMultipleEdges - whether the generator allows multiple parallel edges between the same two vertices (v, w).
        allowingSelfLoops - whether the generator allows self loops from the a vertex to itself.
    • Method Detail

      • getMaxFailures

        public int getMaxFailures()
        Returns the maximum allowed number of consecutive failed attempts to add an edge.
        Returns:
        maxFailure field.
      • setMaxFailures

        public void setMaxFailures​(int maxFailures)
        Sets the maximum allowed number of consecutive failed attempts to add an edge (must be non negative).
        Parameters:
        maxFailures - Maximum allowed (non negative) number of consecutive failed attempts to add an edge.
      • isAllowingMultipleEdges

        public boolean isAllowingMultipleEdges()
        Returns whether the generated graph may contain multiple (parallel) edges between the same two vertices.
        Returns:
        whether the generated graph may contain multiple (parallel) edges between the same two vertices
      • setAllowingMultipleEdges

        public void setAllowingMultipleEdges​(boolean allowingMultipleEdges)
        Sets whether the generated graph may contain multiple (parallel) edges between the same two vertices
        Parameters:
        allowingMultipleEdges - whether the generated graph may contain multiple (parallel) edges between the same two vertices
      • isAllowingSelfLoops

        public boolean isAllowingSelfLoops()
        Returns whether the generated graph may contain multiple (parallel) edges between the same two vertices
        Returns:
        whether the generated graph many contain multiple (parallel) edges between the same two vertices
      • setAllowingSelfLoops

        public void setAllowingSelfLoops​(boolean allowingSelfLoops)
        Sets whether the generated graph may contain multiple (parallel) edges between the same two vertices
        Parameters:
        allowingSelfLoops - whether the generated graph many contain multiple (parallel) edges between the same two vertices