R: Retrieve Edges or Edge IDs Associated with a Given Vertex

get.edges {network} | R Documentation

## Retrieve Edges or Edge IDs Associated with a Given Vertex

### Description

`get.edges` retrieves a list of edges incident on a given vertex; `get.edgeIDs` returns the internal identifiers for those edges, instead. Both allow edges to be selected based on vertex neighborhood and (optionally) an additional endpoint.

### Usage

    get.edges(x, v, alter = NULL, neighborhood = c("out", "in",
        "combined"), na.omit = TRUE)
    get.edgeIDs(x, v, alter=NULL, neighborhood=c("out","in","combined"),
        na.omit=TRUE)
    get.dyads.eids(x, tails, heads,
             neighborhood = c("out", "in", "combined"))

### Arguments

`x` | an object of class `network`
`v` | a vertex ID
`alter` | optionally, the ID of another vertex
`neighborhood` | an indicator for whether we are interested in in-edges, out-edges, or both (relative to `v`). defaults to `'combined'` for undirected networks
`na.omit` | logical; should we omit missing edges?
`tails` | a vector of vertex ID for the 'tails' (v) side of the dyad
`heads` | a vector of vertex ID for the 'heads' (alter) side of the dyad

### Details

By default, `get.edges` returns all out-, in-, or out- and in-edges containing `v`. `get.edgeIDs` is identical, save in its return value, as it returns only the ids of the edges. Specifying a vertex in `alter` causes these edges to be further selected such that alter must also belong to the edge – this can be used to extract edges between two particular vertices. Omission of missing edges is accomplished via `na.omit`. Note that for multiplex networks, multiple edges or edge ids can be returned.

The function `get.dyads.eids` simplifies the process of looking up the edge ids associated with a set of 'dyads' (tail and head vertex ids) for edges. It only is intended for working with non-multiplex networks and will return a warning and `NA` value for any dyads that correspond to multiple edges. The value `numeric(0)` will be returned for any dyads that do not have a corresponding edge.

### Value

For `get.edges`, a list of edges. For `get.edgeIDs`, a vector of edge ID numbers. For `get.edgeIDs`, a list of edge IDs corresponding to the dyads defined by the vertex ids in `tails` and `heads`

### 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.neighborhood`, `valid.eids`

### 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)

    get.edges(g,1,neighborhood="out")
    get.edgeIDs(g,1,neighborhood="in")

[Package network version 1.13.0.1 Index]