commute_time_distance | R Documentation |
This function computes the commute-time distance between nodes in a graph using either eigenvalue or pseudoinverse methods.
commute_time_distance(A, ncomp = nrow(A) - 1)
A |
A symmetric, non-negative matrix representing the adjacency matrix of the graph |
ncomp |
Integer, number of components to use in the computation, default is (nrow(A) - 1) |
A list with the following components:
eigenvectors |
Matrix, eigenvectors of the matrix M |
eigenvalues |
Vector, eigenvalues of the matrix M |
cds |
Matrix, the computed commute-time distances |
gap |
Numeric, the gap between the two largest eigenvalues |
The returned object has class "commute_time" and "list".
# Create an example adjacency matrix
A <- matrix(c(0, 1, 1, 0,
1, 0, 1, 1,
1, 1, 0, 1,
0, 1, 1, 0), nrow = 4, byrow = TRUE)
# Compute the commute-time distance
result <- commute_time_distance(A)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.