Learn R Programming

migraph (version 0.6.6)

create: Create networks with particular structures

Description

These functions create a variety of different network objects. Despite the common function names and syntax with existing packages, the common n argument can not only be passed a single integer to return a one-mode network, but also a vector of two integers to return a two-mode network.

Usage

create_empty(n)

create_complete(n)

create_ring(n, width = 1, directed = FALSE, ...)

create_components(n, components = 2)

create_star(n, directed = "in")

Arguments

n

Number of nodes. If a single integer is given, e.g. n = 10, the function will create a one-mode network. If a vector of two integers is given, e.g. n = c(5,10), the function will create a two-mode network.

width

The width or breadth of the ring. This is typically double the degree.

directed

One of the following options: "in", "out", or "none".

...

Additional arguments passed on to igraph.

components

Number of components to create.

Value

By default an igraph object will be returned, but this can be coerced into other types of objects using as_matrix(), as_tidygraph(), or as_network().

Details

create_empty() creates an empty graph of the given dimensions.

create_complete() creates a filled graph of the given dimensions.

create_ring() creates a ring or chord graph of the given dimensions that loops around is of a certain width or thickness.

create_components() creates a graph in which the nodes are clustered into separate components.

See Also

as_matrix as_tidygraph as_network

Other creation: generate

Examples

Run this code
# NOT RUN {
g <- create_empty(c(8,6))
plot(g)
g <- create_complete(c(8,6))
plot(g)
g <- create_ring(c(8,6), width = 2)
plot(g)
plot(create_components(c(10, 12), components = 3))
plot(create_star(c(12,1)))
# }

Run the code above in your browser using DataLab