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

neighborhood

Compute Neighborhood Structures of Specified Order


Description

For a given graph, returns the specified neighborhood structure at the selected order(s).

Usage

neighborhood(dat, order, neighborhood.type = c("in", "out", "total"),
    mode = "digraph", diag = FALSE, thresh = 0, return.all = FALSE,
    partial = TRUE)

Arguments

dat

one or more graphs.

order

order of the neighborhood to extract.

neighborhood.type

neighborhood type to employ.

mode

"digraph" if dat is directed, otherwise "graph".

diag

logical; do the diagonal entries of dat contain valid data?

thresh

dichotomization threshold to use for dat; edges whose values are greater than thresh are treated as present.

return.all

logical; return neighborhoods for all orders up to order?

partial

logical; return partial (rather than cumulative) neighborhoods?

Details

The adjacency matrix associated with the ith order neighborhood is defined as the identity matrix for order 0, and otherwise depends on the type of neighborhood involved. For input graph G=(V,E), let the base relation, R, be given by the underlying graph of G (i.e., G U G^T) if total neighborhoods are sought, the transpose of G if incoming neighborhoods are sought, or G otherwise. The partial neighborhood structure of order i>0 on R is then defined to be the digraph on V whose edge set consists of the ordered pairs (j,k) having geodesic distance i in R. The corresponding cumulative neighborhood is formed by the ordered pairs having geodesic distance less than or equal to i in R.

Neighborhood structures are commonly used to parameterize various types of network autocorrelation models. They may also be used in the calculation of certain types of local structural indices; gapply provides an alternative function which can be used for this purpose.

Value

An array or adjacency matrix containing the neighborhood structures (if dat is a single graph); if dat contains multiple graphs, then a list of such structures is returned.

Author(s)

Carter T. Butts buttsc@uci.edu

See Also

Examples

#Draw a random graph
g<-rgraph(10,tp=2/9)

#Show the total partial out-neighborhoods
neigh<-neighborhood(g,9,neighborhood.type="out",return.all=TRUE)
par(mfrow=c(3,3))
for(i in 1:9)
  gplot(neigh[i,,],main=paste("Partial Neighborhood of Order",i))

#Show the total cumulative out-neighborhoods
neigh<-neighborhood(g,9,neighborhood.type="out",return.all=TRUE,
    partial=FALSE)
par(mfrow=c(3,3))
for(i in 1:9)
  gplot(neigh[i,,],main=paste("Cumulative Neighborhood of Order",i))

sna

Tools for Social Network Analysis

v2.6
GPL (>= 2)
Authors
Carter T. Butts [aut, cre, cph]
Initial release
2020-10-5

We don't support your browser anymore

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