Learn R Programming

network (version 1.0-1)

get.edges: 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)

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)
na.omit
logical; should we omit missing edges?

Value

  • For get.edges, a list of edges. For get.edgeIDs, a vector of edge ID numbers.

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

References

Butts, C.T. 2002. ``Memory Structures for Relational Data in R: Classes and Interfaces'' Working Paper.

See Also

get.neighborhood

Examples

Run this code
#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")

Run the code above in your browser using DataLab