| netstats_om_nwalks | R Documentation |
This function calculates the number of walks of length k between any two vertices in an unweighted one-mode network.
netstats_om_nwalks(net, k)
net |
An unweighted one-mode network adjacency matrix. |
k |
A numerical value that corresponds to the length of the paths to be computed. |
A nice result from graph theory is that the number of walks of length k between vertices i and j can be found by:
A_{ij}^k
This function assumes that there are no self-loops (i.e., the diagonal of the matrix is 0).
An n x n matrix of counts of paths.
Kevin A. Carson kacarson@arizona.edu, Diego F. Leal dflc@arizona.edu
# For this example, we generate a random one-mode graph with the sna package.
#creating the random network with 10 actors
set.seed(9999)
rnet <- matrix(sample(c(0,1), 10*10, replace = TRUE, prob = c(0.8,0.2)),
nrow = 10, ncol = 10, byrow = TRUE)
diag(rnet) <- 0 #setting self ties to 0
#counting the walks of length 2
netstats_om_nwalks(rnet, k = 2)
#counting the walks of length 5
netstats_om_nwalks(rnet, k = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.