network.edgecount {network}R Documentation

Return the Number of Edges in a Network Object

Description

network.edgecount returns the number of edges within a network, removing those flagged as missing if desired.

Usage

network.edgecount(x, na.omit = TRUE)

Arguments

x

an object of class network

na.omit

logical; omit edges with na==TRUE from the count?

Details

The return value network.edgecount is equal to x%n%"mnext"-1, minus the number of NULL edges (and missing edges, if na.omit==TRUE). Note that g%n%"mnext"-1 cannot, by itself, be counted upon to be an accurate count of the number of edges!

Value

The number of edges

Warning

network.edgecount uses the real state of the network object to count edges, not the state it hypothetically should have. Thus, if you add extra edges to a non-multiplex network, directed edges to an undirected network, etc., the actual number of edges in the object will be returned (and not the number you would expect if you relied only on the putative number of possible edges as reflected by the network.indicators). Don't create network objects with contradictory attributes unless you know what you are doing.

Author(s)

Carter T. Butts buttsc@uci.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

get.network.attribute

Examples

#Create a network with three edges
m<-matrix(0,3,3)
m[1,2]<-1; m[2,3]<-1; m[3,1]<-1
g<-network(m)
network.edgecount(g)==3   #Verify the edgecount

[Package network version 1.7 Index]