pathdist {lazy.mat} | R Documentation |
Calculation of Path Distance
pathdist(S, minS = 1, sort = 2, dump = 0, print = 1, debug = 0)
S |
Input path matrix |
minS |
The smallest value of S matrix which indicates connection. |
sort |
= 0 not to sort the result |
dump |
= 0 to output the # of paths of length L, L=2,3,... . |
print |
= 1 to print result |
debug |
= 1 to print intermediate result |
Let V[,,1] = S. Then, the number of paths of length L, L=2,3,...
can be calculated as
V[,,L] = S %*% V[,,L-1] - Diag(S) %*% V[,,L-1] -
S %*% Diag(V[,,L-1]) + Diag(S) %*% Diag(V[,,L-1])
Elementwise,
V[i,j,L] = ∑_{k!=i & k!=j} S[i,k] V[k,j,L-1]
By default, the rows and columns of the resulting matrices will be sorted
in order to facilitate the interpretation.
S ns x ns input path matrix
D ns x ns minimum path distance from i to j.
D[i,j]=L member i can reach member j via L-1 menbers.
D[i,j]=NA means no conection.
C ns x ns connection from i to j
C[i,j]=1 means i and j are connected, C[i,j]=0 means no connection.
SS ns x ns sorted input path matrix
DD ns x ns sorted minimum path dist from i to j
CC ns x ns sorted connection from i to j
nblk 1 x 1 # of blocks
sblk nblk x 1 # of members in each block
sort 1 x 1 sort parameter
od ns x 1 new order of original row/col
that is, to sort, use SS = S[order, order]
error 1 x 1 = 0 if the connection matrix can be block diagonalized.
V An array of the V[,,L] matrices
set.seed(1701) n <- 8 S <- sample( c(0,0,0,0,0,1), n*(n-1)/2, replace=1 ) S <- vechinv(S,nodiag=1) res <- pathdist(S, print=2, dump=1)