R/make_generate.R
, R/manip_correlation.R
make_random.Rd
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_configuration()
generates a random network consistent with a
given degree distribution.
generate_man()
generates a random network conditional on the dyad census
of Mutual, Asymmetric, and Null dyads, respectively.
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_configuration(.data)
generate_man(n, man = NULL)
generate_utilities(n, steps = 1, volatility = 0, threshold = 0)
generate_permutation(.data, with_attr = TRUE)
Given:
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.
Proportion of possible ties in the network that are realised or, if integer greater than 1, the number of ties in the network.
Whether to generate network as directed. By default FALSE.
Logical whether any attributes of the object should be retained. By default TRUE.
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
Vector of Mutual, Asymmetric, and Null dyads, respectively.
Can be specified as proportions, e.g. c(0.5, 0.5, 0.5)
,
or as a count, e.g. c(10,0,20)
.
Is inferred from n
if it is an existing network object.
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.
Other makes:
make_cran
,
make_create
,
make_ego
,
make_explicit
,
make_learning
,
make_motifs
,
make_play
,
make_read
,
make_stochastic
,
make_write
graphr(generate_random(12, 0.4))
# graphr(generate_random(c(6, 6), 0.4))