R: Network Objects

network {network} | R Documentation

## Network Objects

### Description

Construct, coerce to, test for and print `network` objects.

### Usage

    is.network(x)

    as.network(x, ...)

    network(x, vertex.attr = NULL, vertex.attrnames = NULL,
      directed = TRUE, hyper = FALSE, loops = FALSE, multiple = FALSE,
      bipartite = FALSE, ...)

    network.copy(x)

    ## S3 method for class 'network'
    print(x, matrix.type = which.matrix.type(x),
      mixingmatrices = FALSE, na.omit = TRUE, print.adj = FALSE, ...)

    ## S3 method for class 'network'
    summary(object, na.omit = TRUE,
      mixingmatrices = FALSE, print.adj = TRUE, ...)

### Arguments

`x` | for `network`, a matrix giving the network structure in adjacency, incidence, or edgelist form; otherwise, an object of class `network`.
`...` | additional arguments.
`vertex.attr` | optionally, a list containing vertex attributes.
`vertex.attrnames` | optionally, a list containing vertex attribute names.
`directed` | logical; should edges be interpreted as directed?
`hyper` | logical; are hyperedges allowed?
`loops` | logical; should loops be allowed?
`multiple` | logical; are multiplex edges allowed?
`bipartite` | count; should the network be interpreted as bipartite? If present (i.e., non-NULL, non-FALSE) it is the count of the number of actors in the bipartite network. In this case, the number of nodes is equal to the number of actors plus the number of events (with all actors preceeding all events). The edges are then interpreted as nondirected. Values of bipartite==0 are permited, indicating a bipartite network with zero-sized first partition.
`matrix.type` | one of `"adjacency"`, `"edgelist"`, `"incidence"`. See `edgeset.constructors` for details and optional additional arguments
`mixingmatrices` | logical; print the mixing matrices for the discrete attributes?
`na.omit` | logical; omit summarization of missing attributes in `network`?
`print.adj` | logical; print the network adjacency structure?
`object` | an object of class `network`.

### Details

`network` constructs a `network` class object from a matrix representation. If the `matrix.type` parameter is not specified, it will make a guess as to the intended `edgeset.constructors` function to call based on the format of these input matrices. If the class of `x` is not a matrix, network construction can be dispatched to other methods. For example, If the `ergm` package is loaded, `network()` can function as a shorthand for `as.network.numeric` with `x` as an integer specifying the number of nodes to be created in the random graph.

If the `ergm` package is loaded, `network` can function as a shorthand for `as.network.numeric` if `x` is an integer specifying the number of nodes. See the help page for `as.network.numeric` in `ergm` package for details.

`network.copy` creates a new `network` object which duplicates its supplied argument. (Direct assignment with `<-` should be used rather than `network.copy` in most cases.)

`as.network` tries to coerce its argument to a network, using the `as.network.matrix` functions if `x` is a matrix. (If the argument is already a network object, it is returned as-is and all other arguments are ignored.)

`is.network` tests whether its argument is a network (in the sense that it has class `network`).

`print.network` prints a network object in one of several possible formats. It also prints the list of global attributes of the network.

`summary.network` provides similar information.

### Value

`network`, `as.network`, and `print.network` all return a network class object; `is.network` returns TRUE or FALSE.

### Note

Between versions 0.5 and 1.2, direct assignment of a network object created a pointer to the original object, rather than a copy. As of version 1.2, direct assignment behaves in the same manner as `network.copy`. Direct use of the latter is thus superfluous in most situations, and is discouraged.

Many of the network package functions modify their network object arguments in-place. For example, `set.network.attribute(net,"myVal",5)` will have the same effect as `net<-set.network.attribute(net,"myVal",5)`. Unfortunately, the current implementation of in-place assignment breaks when the network argument is an element of a list or a named part of another object. So `set.network.attribute(myListOfNetworks[[1]],"myVal",5)` will silently fail to modify its network argument, likely leading to incorrect output.

### Author(s)

Carter T. Butts buttsc@uci.edu and David Hunter dhunter@stat.psu.edu

### References

Butts, C. T. (2008). “network: a Package for Managing Relational Data in R.” Journal of Statistical Software, 24(2). http://www.jstatsoft.org/v24/i02/

### See Also

`network.initialize`, `attribute.methods`, `as.network.matrix`, `as.matrix.network`, `deletion.methods`, `edgeset.constructors`, `network.indicators`, `plot.network`

### Examples

    m <- matrix(rbinom(25,1,.4),5,5)
    diag(m) <- 0
    g <- network(m, directed=FALSE)
    summary(g)

    h <- network.copy(g)       #Note: same as h<-g
    summary(h)

[Package network version 1.16.0 Index]