R: Network Operators

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
    ## S3 method for class 'network'
    !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

In general, the binary network operators function by producing a new network object whose edge structure is based on that of the input networks. The properties of the new structure depend upon the inputs as follows:

- The size of the new network is equal to the size of the input networks (for all operators save `%c%`), which must themselves be of equal size. Likewise, the `bipartite` attributes of the inputs must match, and this is preserved in the output.

- If either input network allows loops, multiplex edges, or hyperedges, the output acquires this property. (If both input networks do not allow these features, then the features are disallowed in the output network.)

- If either input network is directed, the output is directed; if exactly one input network is directed, the undirected input is treated as if it were a directed network in which all edges are reciprocated.

- Supplemental attributes (including vertex names, but not edgwise missingness) are not transferred to the output.

The unary operator acts per the above, but with a single input. Thus, the output network has the same properties as the input, with the exception of supplemental attributes.

The behavior of the composition operator, `%c%`, is somewhat more complex than the others. In particular, it will return a bipartite network whenever either input network is bipartite or the vertex names of the two input networks do not match (or are missing). If both inputs are non-bipartite and have identical vertex names, the return value will have the same structure (but with loops). This behavior corresponds to the interpretation of the composition operator as counting walks on labeled sets of vertices.

Hypergraphs are not yet supported by these routines, but ultimately will be (as suggested by the above).

The specific operations carried out by these operators are generally self-explanatory in the non-multiplex case, but semantics in the latter circumstance bear elaboration. The following summarizes the behavior of each operator:

`+`

  An (i,j) edge is created in the return graph for every (i,j) edge in each of the input graphs.

`-`

  An (i,j) edge is created in the return graph for every (i,j) edge in the first input that is not matched by an (i,j) edge in the second input; if the second input has more (i,j) edges than the first, no (i,j) edges are created in the return graph.

`*`

  An (i,j) edge is created for every pairing of (i,j) edges in the respective input graphs.

`%c%`

  An (i,j) edge is created in the return graph for every edge pair (i,k),(k,j) with the first edge in the first input and the second edge in the second input.

`!`

  An (i,j) edge is created in the return graph for every (i,j) in the input not having an edge.

`|`

  An (i,j) edge is created in the return graph if either input contains an (i,j) edge.

`&`

  An (i,j) edge is created in the return graph if both inputs contain an (i,j) edge.

Semantics for missing-edge cases follow from the above, under the interpretation that edges with `na==TRUE` are viewed as having an unknown state. Thus, for instance, `x*y` with `x` having 2 (i,j) non-missing and 1 missing edge and `y` having 3 respective non-missing and 2 missing edges will yield an output network with 6 non-missing and 9 missing (i,j) edges.

### Value

The resulting network.

### 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)[,]

[Package network version 1.13.0.1 Index]