| nbOrder | R Documentation | 
Given a square binary adjacency matrix, the function
nbOrder determines the integer matrix of neighbourhood orders
(shortest-path distance).
nbOrder(neighbourhood, maxlag = Inf)
| neighbourhood | a square, numeric or logical, and usually symmetric matrix with
finite entries (and usually zeros on the diagonal) which indicates
vertex adjacencies, i.e., first-order neighbourhood (interpreted as
 | 
| maxlag | positive scalar integer specifying an upper bound for the
neighbourhood order. The default ( | 
An integer matrix of neighbourhood orders, i.e., the shortest-path
distance matrix of the vertices.
The dimnames of the input neighbourhood matrix are preserved.
Sebastian Meyer
nblag from the spdep package
## generate adjacency matrix
set.seed(1)
n <- 6
adjmat <- matrix(0, n, n)
adjmat[lower.tri(adjmat)] <- sample(0:1, n*(n-1)/2, replace=TRUE)
adjmat <- adjmat + t(adjmat)
adjmat
## determine neighbourhood order matrix
nblags <- nbOrder(adjmat)
nblags
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.