def motif3struct(cmatrix, weighted): """ Counts occurrences of three-node structural motifs Parameters ---------- cmatrix : connection/adjacency matrix (For weighted graph W(all weights [0,1]) ) weighted : {False, True} Returns ------- weighted == True: I : Returns intensity and (optionally) coherence and motif counts. Weighted structural motif metrics. Reference: Onnela et al. 2005, Phys Rev E 71:065103; Mika Rubinov, UNSW, 2007 (last modified July 2008) weighted == False: f : binary motif count Reference: Milo et al., 2002, Science Mika Rubinov, UNSW, 2007 (last modified July 2008) """ if weighted: m = bct.to_gslm(cmatrix.tolist()) str = bct.motif3struct_wei(m) strnp = bct.from_gsl(str) bct.gsl_free(m) bct.gsl_free(str) return np.asarray(strnp) else: m = bct.to_gslm(cmatrix.tolist()) str = bct.motif3struct_bin(m) strnp = bct.from_gsl(str) bct.gsl_free(m) bct.gsl_free(str) return np.asarray(strnp)
def motif3struct_bin(*args): return _bct.motif3struct_bin(*args)
def motif3struct_bin(*args): """motif3struct_bin(gsl_matrix A) -> gsl_vector""" return _bct.motif3struct_bin(*args)