View source: R/npaths_deprecatedV100.R
| computeNPaths | R Documentation |
computeNPaths() has been deprecated starting on version 1.0.0 of the dream package. Please use the netstats_om_nwalks() function and see the NEWS.md file for more details.
This function calculates the number of walks of length k between any two vertices in an unweighted one-mode network.
computeNPaths(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 is similar to the functions provided in igraph that provide the walks between two vertices. The main difference is that this function provides the counts of paths between all vertices in the network. In addition, 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 walks.
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 paths of length 2
computeNPaths(rnet, k = 2)
#counting the paths of length 5
computeNPaths(rnet, k = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.