These functions are similar to the create_* functions, but include some element of randomisation. They are particularly useful for creating a distribution of networks for exploring or testing network properties.

  • generate_random() generates a random network with ties appearing at some probability.

  • generate_smallworld() generates a small-world structure via ring rewiring at some probability.

  • generate_scalefree() generates a scale-free structure via preferential attachment at some probability.

  • generate_permutation() generates a permutation of the network using a Fisher-Yates shuffle on both the rows and columns (for a one-mode network) or on each of the rows and columns (for a two-mode network).

  • generate_utilities() generates a random utility matrix.

These functions can create either one-mode or two-mode networks. To create a one-mode network, pass the main argument n a single integer, indicating the number of nodes in the network. To create a two-mode network, pass n a vector of two integers, where the first integer indicates the number of nodes in the first mode, and the second integer indicates the number of nodes in the second mode. As an alternative, an existing network can be provided to n and the number of modes, nodes, and directedness will be inferred.

generate_random(n, p = 0.5, directed = FALSE, with_attr = TRUE)

generate_smallworld(n, p = 0.05, directed = FALSE, width = 2)

generate_scalefree(n, p = 1, directed = FALSE)

generate_permutation(.data, with_attr = TRUE)

generate_utilities(n, steps = 1, volatility = 0, threshold = 0)




  • A single integer, e.g. n = 10, a one-mode network will be created.

  • A vector of two integers, e.g. n = c(5,10), a two-mode network will be created.

  • A manynet-compatible object, a network of the same dimensions will be created.


Power of the preferential attachment, default is 1.


Whether to generate network as directed. By default FALSE.


Logical whether any attributes of the object should be retained. By default TRUE.


Integer specifying the width of the ring, breadth of the branches, or maximum extent of the neighbourbood.


An object of a manynet-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package


Number of simulation steps to run. By default 1: a single, one-shot simulation. If more than 1, further iterations will update the utilities depending on the values of the volatility and threshold parameters.


How much change there is between steps. Only if volatility is more than 1 do further simulation steps make sense. This is passed on to stats::rnorm as the sd or standard deviation parameter.


This parameter can be used to mute or disregard stepwise changes in utility that are minor. The default 0 will recognise all changes in utility, but raising the threshold will mute any changes less than this threshold.


By default a tbl_graph object is returned, but this can be coerced into other types of objects using as_edgelist(), as_matrix(), as_tidygraph(), or as_network().

By default, all networks are created as undirected. This can be overruled with the argument directed = TRUE. This will return a directed network in which the arcs are out-facing or equivalent. This direction can be swapped using to_redirected(). In two-mode networks, the directed argument is ignored.


Erdos, Paul, and Alfred Renyi. (1959). "On Random Graphs I" Publicationes Mathematicae. 6: 290–297.

Watts, Duncan J., and Steven H. Strogatz. 1998. “Collective Dynamics of ‘Small-World’ Networks.” Nature 393(6684):440–42. doi:10.1038/30918 .

Barabasi, Albert-Laszlo, and Reka Albert. 1999. “Emergence of Scaling in Random Networks.” Science 286(5439):509–12. doi:10.1126/science.286.5439.509 .

See also

Other makes: create, learning, play, read, write()


autographr(generate_random(12, 0.4))

# autographr(generate_random(c(6, 6), 0.4))
autographr(generate_smallworld(12, 0.025))

autographr(generate_smallworld(12, 0.25))

autographr(generate_scalefree(12, 0.25))

autographr(generate_scalefree(12, 1.25))