get_neighborhood: Get neighbors 'k' or fewer steps away

Description Usage Arguments Details Value Examples

Description

Function iterates over graph to identify for a given node all nodes that are no more than k steps apart.

Usage

1
get_neighborhood(adj, start, k = 1L)

Arguments

adj

numeric matrix specifying the adjacency matrix.

start

integer specifying the row of the start node in the adjacency matrix.

k

integer specifying the maximum distance to the start node.

Details

k < 1 will be set to k = 1.

Value

A numeric matrix of two columns containing nodes indices and the geodesic distance to the start nodes of all nodes k or fewer steps away from start.

Examples

1
2
3
4
5
6
7
8
# generate watts strogatz graph
network = grow_ws(n = 100, k = 10, p = .5)

# get neighborhood of second node
get_neighborhood(network, 2)

# get 3-hop neighborhood of second node
get_neighborhood(network, 2, k = 3)

memnet documentation built on May 2, 2019, 9:35 a.m.