as.edgelist: Convert a network object into a numeric edgelist matrix

Description Usage Arguments Details Value Note See Also Examples

Description

Constructs an edgelist in a sorted format with defined attributes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  ## S3 method for class 'network'
as.edgelist(x, attrname = NULL, as.sna.edgelist = FALSE, 
  inverted = NULL, ...)
  
  ## S3 method for class 'matrix'
as.edgelist(x, n, directed = TRUE, bipartite = FALSE, 
  loops = FALSE, inverted = FALSE, vnames = seq_len(n), ...)
  
  is.edgelist(x)
  

Arguments

x

a network object with additional class added indicating how it should be dispatched.

attrname

optionally, the name of an edge attribute to use for edge values

as.sna.edgelist

logical; should the edgelist be returned in edgelist form expected by the sna package?

inverted

logical; value is passed to the 'inverted' flag on the edgelist returned

n

integer number of vertices in network, value passed to the 'n' flag on edgelist returned

vnames

vertex names (defaults to vertex ids) to be attached to edgelist for sna package compatibility

directed

logical; is network directed, value passed to the 'directed' flag on edgelist returned

bipartite

logical or integer; is network bipartite, value passed to the 'bipartite' flag on edgelist returned

loops

logical; are self-loops allowed in network?, value passed to the 'loops' flag on edgelist returned

...

additional arguments to other methods

Details

Constructs a edgelist matrix from a network, sorted tails-major order, with tails first, and, for undirected networks, tail < head. This format is required by some reverse-depending packages (i.e. ergm)

The as.matrix.network.edgelist provides similar functionality but it does not enforce ordering or set the edgelist class and so should be slightly faster.

is.edgelist tests if an object has the class 'edgelist'

Value

A matrix in which the first two columns are integers giving the tail (source) and head (target) vertex ids of each edge. The matrix will be given the class edgelist.

The edgelist has additional attributes attached to it:

Note that if the attrname attribute is used the resulting edgelist matrix will have three columns. And if attrname refers to a character attribute, the resulting edgelist matrix will be character rather than numeric.

Note

NOTE: this function was moved to network from the ergm package in network version 1.13

See Also

See also as.matrix.network.edgelist

Examples

1
2
3
4
5
   data(emon)
   as.edgelist(emon[[1]])
   # contrast with unsorted columns of
   as.matrix.network.edgelist(emon[[1]])
  

network documentation built on May 2, 2019, 5:16 p.m.