Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get.neighborhood

Obtain the Neighborhood of a Given Vertex


Description

get.neighborhood returns the IDs of all vertices belonging to the in, out, or combined neighborhoods of v within network x.

Usage

get.neighborhood(x, v, type = c("out", "in", "combined"),
  na.omit = TRUE)

Arguments

x

an object of class network

v

a vertex ID

type

the neighborhood to be computed

na.omit

logical; should missing edges be ignored when obtaining vertex neighborhoods?

Details

Note that the combined neighborhood is the union of the in and out neighborhoods – as such, no vertex will appear twice.

Value

A vector containing the vertex IDs for the chosen neighborhood.

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). https://www.jstatsoft.org/v24/i02/

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

See Also

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)

#Examine the neighborhood of vertex 1
get.neighborhood(g,1,"out")
get.neighborhood(g,1,"in")
get.neighborhood(g,1,"combined")

network

Classes for Relational Data

v1.16.1
GPL (>= 2)
Authors
Carter T. Butts [aut, cre], David Hunter [ctb], Mark Handcock [ctb], Skye Bender-deMoll [ctb], Jeffrey Horner [ctb], Li Wang [ctb]
Initial release
2020-10-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.