networkLite {networkLite}R Documentation

networkLite Constructor Utilities

Description

Constructor methods for networkLite objects.

Usage

networkLite(x, ...)

## S3 method for class 'edgelist'
networkLite(
  x,
  attr = list(vertex.names = seq_len(net_attr[["n"]]), na = logical(net_attr[["n"]])),
  net_attr = attributes(x)[setdiff(names(attributes(x)), c("class", "dim", "dimnames",
    "vnames", "row.names", "names", "mnext"))],
  ...,
  atomize = FALSE
)

## S3 method for class 'matrix'
networkLite(
  x,
  attr = list(vertex.names = seq_len(net_attr[["n"]]), na = logical(net_attr[["n"]])),
  net_attr = attributes(x)[setdiff(names(attributes(x)), c("class", "dim", "dimnames",
    "vnames", "row.names", "names", "mnext"))],
  ...,
  atomize = FALSE
)

## S3 method for class 'numeric'
networkLite(x, directed = FALSE, bipartite = FALSE, ...)

networkLite_initialize(x, directed = FALSE, bipartite = FALSE, ...)

Arguments

x

Either an edgelist class network representation, or a number specifying the network size. The edgelist may be either a tibble or a matrix. If a tibble is passed, it should have integer columns named ".tail" and ".head" for the tails and heads of edges, and may include edge attributes as additional columns. If a matrix is passed, it should have two columns, the first being the tails of edges and the second being the heads of edges; edge attributes are not supported for matrix arguments. Edges should be sorted, first on tails then on heads. See network::as.edgelist for information on producing such edgelist objects from network objects.

...

additional arguments

attr

A named list of vertex attributes, coerced to tibble. Each element of attr should be an atomic vector or list of length equal to the number of nodes in the network.

net_attr

A named list of network attributes. Must include the network size attribute named "n". Defaults to a subset of the attr-style attributes of x for backwards compatibility; it is recommended that new code specify net_attr explicitly rather than relying on this default.

atomize

Logical; should we call atomize on the networkLite before returning it? Note that unlike as.networkLite, the default value here is FALSE.

directed, bipartite

Common network attributes that may be set via arguments to the networkLite.numeric method.

Details

Currently there are several distinct networkLite constructor methods available.

The edgelist method takes an edgelist class object x, a named list of vertex attributes attr, and a named list of network attributes net_attr, and returns a networkLite object, which is a named list with fields el, attr, and gal, corresponding to the arguments x, attr, and net_attr. Missing network attributes directed and bipartite are defaulted to FALSE; the network size attribute n must not be missing.

The numeric method takes a number x as well as the network attributes directed and bipartite (defaulting to FALSE), and returns an empty networkLite with these network attributes and number of nodes x.

The constructor networkLite_initialize is also available for creating an empty networkLite, and its x argument should be a number indicating the size of the networkLite to create.

Within EpiModel, the networkLite data structure is used in the calls to ergm and tergm simulate and summary functions.

Value

A networkLite object constructed according to the inputs.

Examples

edgelist <- cbind(c(1, 2, 3), c(2, 4, 7))
attr(edgelist, "n") <- 10 # network size
vertex_attributes <- list(a = 1:10, b = runif(10))
nwL <- networkLite(edgelist, vertex_attributes)
nwL


[Package networkLite version 1.0.5 Index]