View source: R/compute_reachability.R
| compute_reachability | R Documentation |
Calculates the reachability matrix from an adjacency matrix using Warshall's algorithm. The reachability matrix shows all direct and indirect relationships between elements in a system.
compute_reachability(adj_matrix, include_self = TRUE)
adj_matrix |
A square adjacency matrix (n x n) containing only 0s and 1s. A value of 1 at position (i,j) indicates that element i directly influences element j. |
include_self |
Logical. If |
The function implements Warshall's algorithm for computing the transitive closure of a directed graph. The time complexity is O(n^3) where n is the number of elements.
In standard ISM methodology, the reachability matrix is defined as:
R = (A + I)^k
where A is the adjacency matrix, I is the identity matrix, and k is the
smallest integer such that (A + I)^k = (A + I)^{k+1}.
The diagonal elements being 1 (self-reachability) is essential for correct level partitioning in ISM analysis.
A reachability matrix of the same dimension as the input.
A value of 1 at position (i,j) indicates that element i can reach element j either directly or through intermediate elements.
When include_self = TRUE, diagonal elements are always 1.
Warfield, J. N. (1974). Developing interconnection matrices in structural modeling. IEEE Transactions on Systems, Man, and Cybernetics, SMC-4(1), 81-87. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/TSMC.1974.5408524")}
create_relation_matrix for creating adjacency matrices,
level_partitioning for hierarchical decomposition,
plot_ism for visualization.
# Create a 4x4 adjacency matrix
adj_matrix <- matrix(c(0, 1, 0, 0,
0, 0, 1, 1,
0, 0, 0, 0,
0, 0, 0, 0),
nrow = 4, byrow = TRUE)
# Compute reachability matrix (with self-reachability)
reach_matrix <- compute_reachability(adj_matrix)
print(reach_matrix)
# Note: diagonal elements are 1 (self-reachability)
diag(reach_matrix)
# With named elements
rownames(adj_matrix) <- colnames(adj_matrix) <- c("A", "B", "C", "D")
reach_matrix <- compute_reachability(adj_matrix)
print(reach_matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.