degree.sequence.game         package:igraph         R Documentation

_G_e_n_e_r_a_t_e _r_a_n_d_o_m _g_r_a_p_h_s _w_i_t_h _a _g_i_v_e_n _d_e_g_r_e_e _s_e_q_u_e_n_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     It is often useful to create a graph with given vertex degrees.
     This is exactly what 'degree.sequence.game' does.

_U_s_a_g_e:

     degree.sequence.game(out.deg, in.deg = numeric(0),
          method = c("simple", "vl"), ...) 

_A_r_g_u_m_e_n_t_s:

 out.deg: Numeric vector, the sequence of degrees (for undirected
          graphs) or out-degrees (for directed graphs). For undirected
          graphs its sum should be even. For directed graphs its sum
          should be the same as the sum of 'in.deg'.

  in.deg: For directed graph, the in-degree sequence.

  method: Character, the method for generating the graph. Right now the
          "simple" and "vl" methods are implemented.

     ...: Additional arguments, these are used as graph attributes.

_D_e_t_a_i_l_s:

     The "simple" method connects the out-stubs of the edges
     (undirected graphs) or the out-stubs and in-stubs (directed
     graphs) together. This way loop edges and also multiple edges may
     be generated.

     This method is not adequate if one needs to generate simple graphs
     with a given degree sequence. The multiple and loop edges can be
     deleted, but then the degree sequence is distorted and there is
     nothing to ensure that the graphs are sampled uniformly.

     THe "vl" method is a more sophisticated generator. The algorithm
     and the implementation was done by Fabien Viger and Matthieu
     Latapy. This generator always generates undirected, connected
     simple graphs, it is an error to pass the 'in.deg' argument to it.
     The algorithm relies on first creating an initial (possibly
     unconnected) simple undirected graph with the given degree
     sequence (if this is possible at all). Then some rewiring is done
     to make the graph connected. Finally a Monte-Carlo algorithm is
     used to randomize the graph. The "vl" samples from the undirected,
     connected simple graphs unformly. See <URL:
     http://www-rp.lip6.fr/~latapy/FV/generation.html> for details.

_V_a_l_u_e:

     The new graph object.

_A_u_t_h_o_r(_s):

     Gabor Csardi csardi@rmki.kfki.hu

_S_e_e _A_l_s_o:

     'erdos.renyi.game', 'barabasi.game', 'simplify' to get rid of the
     multiple and/or loops edges.

_E_x_a_m_p_l_e_s:

     ## The simple generator
     g <- degree.sequence.game(rep(2,100))
     degree(g)
     is.simple(g)   # sometimes TRUE, but can be FALSE
     g2 <- degree.sequence.game(1:10, 10:1)
     degree(g2, mode="out")
     degree(g2, mode="in")

     ## The vl generator
     g3 <- degree.sequence.game(rep(2,100), method="vl")
     degree(g3)
     is.simple(g3)  # always TRUE

     ## Exponential degree distribution
     ## Note, that we correct the degree sequence if its sum is odd
     degs <- sample(1:100, 100, replace=TRUE, prob=exp(-0.5*(1:100)))
     if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
     g4 <- degree.sequence.game(degs, method="vl")
     all(degree(g4) == degs)

     ## Power-law degree distribution
     ## Note, that we correct the degree sequence if its sum is odd
     degs <- sample(1:100, 100, replace=TRUE, prob=(1:100)^-2)
     if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
     g5 <- degree.sequence.game(degs, method="vl")
     all(degree(g5) == degs)

