| matrix_to_network {ergmito} | R Documentation |
Manipulation of network objects
Description
This function implements a vectorized version of network::network.adjmat.
It allows us to turn regular matrices into network objects quickly.
Usage
matrix_to_network(x, ...)
## S3 method for class 'matrix'
matrix_to_network(
x,
directed = rep(TRUE, length(x)),
hyper = rep(FALSE, length(x)),
loops = rep(FALSE, length(x)),
multiple = rep(FALSE, length(x)),
bipartite = rep(FALSE, length(x)),
...
)
Arguments
x |
Either a single square matrix (adjacency matrix), or a list of these. |
... |
Further arguments passed to the method. |
directed |
Logical scalar, if |
hyper, multiple, bipartite |
Currently Ignored. Right now all the network objects
created by this function set these parameters as |
loops |
Logical scalar. When |
Details
This version does not support adding the name parameter yet. The function in the network package includes the name of the vertices as an attribute.
Just like in the network function, NA are checked and added accordingly, i.e.
if there is an NA in the matrix, then the value is recorded as a missing edge.
Value
An object of class network. This is a list with the following elements:
-
melMaster Edge List: A named list with length equal to the number of edges in the network. The list itself has 3 elements:inl(tail),outl(head), andatl(attribute). By defaultatl, a list itself, has a single element:na. -
galGraph Attributes List: a named list with the following elements:-
nNumber of nodes -
mnextNumber of edges + 1 -
directed,hyper,loops,multiple,bipartiteThe arguments passed to the function.
-
-
valVertex Attributes List -
ielIn Edgest List -
oelOut Edgest List
Examples
set.seed(155)
adjmats <- rbernoulli(rep(5, 20))
networks <- matrix_to_network(adjmats)