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_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_fire() generates a forest fire model.
generate_islands() generates an islands model.
generate_citations() generates a citations model.
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_smallworld(n, p = 0.05, directed = FALSE, width = 2)
generate_scalefree(n, p = 1, directed = FALSE)
generate_fire(n, contacts = 1, their_out = 0, their_in = 1, directed = FALSE)
generate_islands(n, islands = 2, p = 0.5, bridges = 1, directed = FALSE)
generate_citations(
n,
ties = sample(1:4, 1),
agebins = max(1, n/10),
directed = FALSE
)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.
Power of the preferential attachment, default is 1.
Whether to generate network as directed. By default FALSE.
Integer specifying the width of the ring, breadth of the branches, number of nodes in each blade of a windmill, or maximum extent of the neighbourbood.
Number of contacts or ambassadors chosen from among existing
nodes in the network.
By default 1.
See igraph::sample_forestfire().
Probability of tieing to a contact's outgoing ties. By default 0. In a two-mode network, this is instead the probability of burning across each two-path, and so of closing a four-cycle.
Probability of tieing to a contact's incoming ties.
By default 1.
This is a factor on their_out rather than a probability in its own
right, so their_out = 0 gives a tree whatever their_in is set to.
In a two-mode network, their_out * their_in is instead the probability
that a newly burned node re-ignites and spreads the fire further.
Number of islands or communities to create.
By default 2.
See igraph::sample_islands() for more.
In a two-mode network, each mode is cut into this many blocks,
and a node of each mode that share a block are tied with probability p.
Number of bridges between islands/communities. By default 1.
Number of ties to add per new node. By default a uniform random sample from 1 to 4 new ties. In a two-mode network, each new node of the first mode ties to this many nodes of the second mode, chosen by how recently each was last tied to.
Number of aging bins.
By default either \(\frac{n}{10}\) or 1,
whichever is the larger.
See igraphr::sample_last_cit() for more.
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.
In a one-mode network, each burn step is a single hop, so each tie the fire creates closes a triangle. A tie in a two-mode network crosses modes, so the shortest closure there is the four-cycle rather than the triangle. In a two-mode network each burn step is therefore a two-path hop across the other mode, and each tie the fire creates closes a four-cycle. Both modes grow over the course of the simulation.
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
Leskovec, Jure, Jon Kleinberg, and Christos Faloutsos. 2007. "Graph evolution: Densification and shrinking diameters". ACM transactions on Knowledge Discovery from Data, 1(1): 2-es. doi:10.1145/1217299.1217301
Other makes:
make_collect,
make_create,
make_ego,
make_explicit,
make_learning,
make_play,
make_random,
make_read,
make_write
generate_smallworld(12, 0.025)
#> IGRAPH c80b7a1 U--- 12 24 -- Watts-Strogatz random graph
#> + attr: name (g/c), dim (g/n), size (g/n), nei (g/n), p (g/n), loops
#> | (g/l), multiple (g/l)
#> + edges from c80b7a1:
#> [1] 1-- 2 2-- 3 3-- 4 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10 10--11
#> [11] 11--12 1--12 1-- 3 1--11 2--12 2-- 7 3-- 5 4-- 6 5-- 7 6-- 8
#> [21] 2-- 9 8--10 9--11 10--12
generate_smallworld(12, 0.25)
#> IGRAPH 8650356 U--- 12 24 -- Watts-Strogatz random graph
#> + attr: name (g/c), dim (g/n), size (g/n), nei (g/n), p (g/n), loops
#> | (g/l), multiple (g/l)
#> + edges from 8650356:
#> [1] 2--10 3--12 3-- 4 4-- 5 6--11 6-- 9 7-- 8 8-- 9 9--10 6--10
#> [11] 11--12 1--12 1-- 8 1-- 9 5-- 7 2-- 8 4-- 7 4-- 6 7--10 6-- 8
#> [21] 7-- 9 8--10 9--11 1-- 5
generate_scalefree(12, 0.25)
#> IGRAPH ced5c0f U--- 12 11 -- Barabasi graph
#> + attr: name (g/c), power (g/n), m (g/n), zero.appeal (g/n), algorithm
#> | (g/c)
#> + edges from ced5c0f:
#> [1] 1-- 2 1-- 3 1-- 4 2-- 5 1-- 6 1-- 7 7-- 8 8-- 9 1--10 1--11 4--12
generate_scalefree(12, 1.25)
#> IGRAPH 24f85d6 U--- 12 11 -- Barabasi graph
#> + attr: name (g/c), power (g/n), m (g/n), zero.appeal (g/n), algorithm
#> | (g/c)
#> + edges from 24f85d6:
#> [1] 1-- 2 1-- 3 3-- 4 2-- 5 1-- 6 6-- 7 5-- 8 4-- 9 4--10 2--11 6--12
generate_fire(10)
#>
#> ── # Forest fire model ─────────────────────────────────────────────────────────
#> # A undirected network of 10 nodes and 9 ties
#>
#> ── Ties
#> # A tibble: 9 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 2 5
#> 5 1 6
#> 6 1 7
#> # ℹ 3 more rows
#>
generate_fire(c(10, 6))
#> # A two-mode network of 10 nodes and 6 nodes and 15 ties
#>
#> ── Nodes
#> # A tibble: 16 × 1
#> type
#> <lgl>
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> # ℹ 10 more rows
#>
#> ── Ties
#> # A tibble: 15 × 2
#> from to
#> <int> <int>
#> 1 1 11
#> 2 1 12
#> 3 1 13
#> 4 2 11
#> 5 2 14
#> 6 3 11
#> # ℹ 9 more rows
#>
generate_islands(10)
#> ── # Interconnected islands model ──────────────────────────────────────────────
#> # A undirected network of 10 nodes and 11 ties
#>
#> ── Ties
#> # A tibble: 11 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 2 4
#> 4 3 4
#> 5 4 5
#> 6 3 8
#> # ℹ 5 more rows
#>
generate_islands(c(10, 6))
#> # A two-mode network of 10 nodes and 6 nodes and 21 ties
#>
#> ── Nodes
#> # A tibble: 16 × 1
#> type
#> <lgl>
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> # ℹ 10 more rows
#>
#> ── Ties
#> # A tibble: 21 × 2
#> from to
#> <int> <int>
#> 1 1 12
#> 2 1 13
#> 3 2 13
#> 4 3 11
#> 5 3 12
#> 6 3 13
#> # ℹ 15 more rows
#>
generate_citations(10)
#> ── # Random citation graph based on last citation ──────────────────────────────
#> # A undirected network of 10 nodes and 9 ties
#>
#> ── Ties
#> # A tibble: 9 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 2 4
#> 4 3 5
#> 5 3 6
#> 6 2 7
#> # ℹ 3 more rows
#>
generate_citations(c(10, 6))
#> # A two-mode network of 10 nodes and 6 nodes and 16 ties
#>
#> ── Nodes
#> # A tibble: 16 × 1
#> type
#> <lgl>
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> # ℹ 10 more rows
#>
#> ── Ties
#> # A tibble: 16 × 2
#> from to
#> <int> <int>
#> 1 2 11
#> 2 3 11
#> 3 4 11
#> 4 4 12
#> 5 5 11
#> 6 5 13
#> # ℹ 10 more rows
#>