def reachdist(cmatrix): """ Reachability and distance matrices. For any two nodes u and v, the reachability matrix element (u,v) takes the value of 1 if u and v are connected by a path, and 0 if u and v are disconnected. The distance matrix element (u,v) denotes the length of the shortest path between u and v. Note that this function returns nonzero entries on the main diagonal of the distance matrix, corresponding to the length of the shortest cycles. This function yields the reachability matrix and the distance matrix based on the power of the adjacency matrix - this will execute a lot faster for matrices with low average distance between vertices. Another way to get the reachability matrix and the distance matrix uses breadth-first search (see 'breadthdist'). 'reachdist' seems a little faster most of the time. However, 'breadthdist' uses less memory in many cases. Computes reachability and distance matrices based on the power of the adjacency matrix. Parameters ---------- cmatrix : connection/adjacency matrix Returns ------- R : reachability matrix % D : distance matrix (not returned) Olaf Sporns, Indiana University, 2002/2007/2008 """ # from c code, D is parameter, R is returned m = bct.to_gslm(cmatrix.tolist()) str = bct.reachdist(m) strnp = bct.from_gsl(str) bct.gsl_free(m) bct.gsl_free(str) return np.asarray(strnp)
def reachdist(*args): return _bct.reachdist(*args)
def reachdist(*args): """reachdist(gsl_matrix CIJ) -> gsl_matrix""" return _bct.reachdist(*args)