These functions create networks with particular structural properties.
create_empty()
creates an empty network without any ties.
create_filled()
creates a filled network with every possible tie realised.
create_ring()
creates a ring or chord network where each nodes'
neighbours form a clique.
create_star()
creates a network with a maximally central node.
create_tree()
creates a network with successive branches.
create_lattice()
creates a network that forms a regular tiling.
create_components()
creates a network that clusters nodes into separate components.
create_core()
creates a network in which a certain proportion of 'core' nodes
are densely tied to each other, and the rest peripheral, tied only to the core.
create_explicit()
creates a network based on explicitly
named nodes and ties between them.
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.
create_empty(n, directed = FALSE)
create_filled(n, directed = FALSE)
create_ring(n, directed = FALSE, width = 1, ...)
create_star(n, directed = FALSE)
create_tree(n, directed = FALSE, width = 2)
create_lattice(n, directed = FALSE, width = 8)
create_components(n, directed = FALSE, membership = NULL)
create_core(n, directed = FALSE, membership = NULL)
create_explicit(...)
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.
Logical whether the graph should be directed.
By default directed = FALSE
.
If the opposite direction is desired,
use to_redirected()
on the output of these functions.
Integer specifying the width of the ring, breadth of the branches, or maximum extent of the neighbourbood.
Additional arguments passed on to {igraph}
.
A vector of partition membership as integers.
If left as NULL
(the default), nodes in each mode will be
assigned to two, equally sized partitions.
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.
create_lattice()
creates both two-dimensional grid and triangular
lattices with as even dimensions as possible.
When the width
parameter is set to 4, nodes cannot have (in or out)
degrees larger than 4.
This creates regular square grid lattices where possible.
Such a network is bipartite, that is partitionable into two types that are
not adjacent to any of their own type.
If the number of nodes is a prime number, it will only return a chain
(a single dimensional lattice).
A width
parameter of 8 creates a network where the maximum degree of any
nodes is 8.
This can create a triangular mesh lattice or a Queen's move lattice,
depending on the dimensions.
A width
parameter of 12 creates a network where the maximum degree of
any nodes is 12.
Prime numbers of nodes will return a chain.
create_empty(10)
#> # A undirected network with 10 nodes and 0 ties
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
create_filled(10)
#> # A undirected network with 10 nodes and 45 ties
#> # A tibble: 45 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 1 5
#> 5 1 6
#> 6 1 7
#> # ℹ 39 more rows
create_ring(8, width = 2)
#> # A undirected network with 8 nodes and 16 ties
#> # A tibble: 16 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 7
#> 4 1 8
#> 5 2 3
#> 6 2 4
#> # ℹ 10 more rows
create_star(12)
#> # A undirected network with 12 nodes and 11 ties
#> # A tibble: 11 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 1 5
#> 5 1 6
#> 6 1 7
#> # ℹ 5 more rows
create_tree(c(7,8))
#> # A two-mode network with 15 nodes and 14 ties
#> # A tibble: 15 × 1
#> type
#> <lgl>
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> # ℹ 9 more rows
#> # A tibble: 14 × 2
#> from to
#> <int> <int>
#> 1 1 8
#> 2 1 9
#> 3 1 10
#> 4 2 8
#> 5 2 11
#> 6 2 12
#> # ℹ 8 more rows
create_lattice(12, width = 4)
#> # A undirected network with 12 nodes and 17 ties
#> # A tibble: 17 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 4
#> 3 2 3
#> 4 2 5
#> 5 3 6
#> 6 4 5
#> # ℹ 11 more rows
create_components(10, membership = c(1,1,1,2,2,2,3,3,3,3))
#> # A undirected network with 10 nodes and 12 ties
#> # A tibble: 12 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 2 3
#> 4 4 5
#> 5 4 6
#> 6 5 6
#> # ℹ 6 more rows
create_core(6)
#> # A undirected network with 6 nodes and 12 ties
#> # A tibble: 12 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 1 5
#> 5 1 6
#> 6 2 3
#> # ℹ 6 more rows
create_explicit(A -+ B, B -+ C, A +-+ C, D)
#> # A labelled, directed network with 4 nodes and 4 arcs
#> # A tibble: 4 × 1
#> name
#> <chr>
#> 1 A
#> 2 B
#> 3 C
#> 4 D
#> # A tibble: 4 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 2 3
#> 3 3 1
#> 4 1 3