network.operators {network}R Documentation

Network Operators

Description

These operators allow for algebraic manipulation of relational structures.

Usage

## S3 method for class 'network':
e1 + e2
## S3 method for class 'network':
e1 - e2
## S3 method for class 'network':
e1 * e2
## S3 method for class 'network':
e1 %c% e2
! e1
## S3 method for class 'network':
e1 | e2
## S3 method for class 'network':
e1 & e2

Arguments

e1 an object of class network.
e2 another network.

Details

A more useful “usage” statement than the above (but prohibited by R's overzealous documentation restrictions from appearing there) is as follows:

x + y
x - y
x * y
x %c% y

!x
x | y
x & y

In general, the binary network operators currently function by converting their arguments to adjacency matrices, carrying out the specified operation on those matrices, and then returning the result in network form. This is rather inefficient, and results in the loss of other attributes; such poor behavior is not guaranteed to be maintained in future versions of the network package.

Apart from the above, the specific operations carried out by these operators are mostly self-explanatory. One exception to this is x %c% y, which returns the network formed from the composition of graphs x and y (respectively). (Note that this may contain loops, whether or not the original networks allowed them.)

Slightly different behavior is exhibited by the unary operator, !, which returns the complement of its argument. The graph which is returned contains all attributes of the original, save for edge attributes (as none of the original edges are retained). Note that the complement of a large, sparse graph has many edges, with concomitant memory consumption. When working with such graphs, consider whether some other mechanism (e.g., adjacency checking on the original graph) might prove more efficient.

Value

The resulting graph object.

Note

Currently, there is a naming conflict between the composition operator and the %c% operator in the sna package. This will be resolved in future releases; for the time being, one can determine which version of %c% is in use by varying which package is loaded first.

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/

Wasserman, S. and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: University of Cambridge Press.

See Also

network.extraction

Examples

#Create an in-star
m<-matrix(0,6,6)
m[2:6,1]<-1
g<-network(m)
plot(g)

#Compose g with its transpose
gcgt<-g %c% (network(t(m)))
plot(gcgt)
gcgt

#Show the complement of g
!g

#Perform various arithmatic and logical operations
(g+gcgt)[,] == (g|gcgt)[,]             #All TRUE
(g-gcgt)[,] == ((g|gcgt)&(!(g&gcgt)))[,]
(g*gcgt)[,] == (g&gcgt)[,]

[Package network version 1.4-1 Index]