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

ego.extract

Extract Egocentric Networks from Complete Network Data


Description

ego.extract takes one or more input graphs (dat) and returns a list containing the egocentric networks centered on vertices named in ego, using adjacency rule neighborhood to define inclusion.

Usage

ego.extract(dat, ego = NULL, neighborhood = c("combined", "in",
    "out"))

Arguments

dat

one or more graphs.

ego

a vector of vertex IDs, or NULL if all are to be selected.

neighborhood

the neighborhood to use.

Details

The egocentric network (or “ego net”) of vertex v in graph G is defined as G[v U N(v)] (i.e., the subgraph of G induced by v and its neighborhood). The neighborhood employed by ego.extract is selected by the eponymous argument: "in" selects in-neighbors, "out" selects out-neighbors, and "combined" selects all neighbors. In the event that one of the vertices selected by ego has no qualifying neighbors, ego.extract will return a degenerate (1 by 1) adjacency matrix containing that individual's diagonal entry.

Vertices within the returned matrices are maintained in their original order, save for ego (who is always listed first). The ego nets themselves are returned in the order specified in the ego parameter (or their vertex order, if no value was specified).

ego.extract is useful for finding local properties associated with particular vertices. To compute functions of neighbors' covariates, see gapply.

Value

A list containing the adjacency matrices for the ego nets of each vertex in ego.

Author(s)

Carter T. Butts buttsc@uci.edu

References

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

See Also

Examples

#Generate a sample network
g<-rgraph(10,tp=1.5/9)

#Extract some ego nets
g.in<-ego.extract(g,neighborhood="in")
g.out<-ego.extract(g,neighborhood="out")
g.comb<-ego.extract(g,neighborhood="in")

#View some networks
g.comb

#Compare ego net size with degree
all(sapply(g.in,NROW)==degree(g,cmode="indegree")+1)    #TRUE
all(sapply(g.out,NROW)==degree(g,cmode="outdegree")+1)  #TRUE
all(sapply(g.comb,NROW)==degree(g)/2+1)        #Usually FALSE!

#Calculate egocentric network density
ego.size<-sapply(g.comb,NROW)
if(any(ego.size>2))
  sapply(g.comb[ego.size>2],function(x){gden(x[-1,-1])})

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.