def edge_betweenness_bin(*args): return _bct.edge_betweenness_bin(*args)
def edge_betweenness_bin(*args): """edge_betweenness_bin(gsl_matrix G) -> gsl_matrix""" return _bct.edge_betweenness_bin(*args)
def edge_betweenness(cmatrix, weighted): """ Edge betweenness centrality The fraction of all shortest paths in the network that traverse a given edge (link). This function outputs an edge betweenness matrix. Note that zero entries may correspond to an absence of an edge, or to an edge with betweenness of 0 -- a comparison with the connectivity matrix will clear up potential confusion. This function may also return nodal betweenness centrality. Parameters ---------- cmatrix : connection matrix, (distance matrix in weighted case) weighted : {True, False} Returns ------- weighted == False: EBC : edge betweenness centrality EBC, for a binary graph G BC : vertex betweenness centrality BC Betweenness may be normalised to [0,1] via EBC/[(N-1)(N-2)] Brandes's modified breadth-first search; J Math Sociol (2001) 25:163-177. Mika Rubinov, UNSW, 2007 (last modified July 2008). weighted == True: EBC : edge betweenness centrality EBC for weighted directed graph BC : vertex betweenness centrality BC The input matrix must be a mapping from weight to distance (eg. higher correlations may be interpreted as short distances - hence an inverse mapping is appropriate in that case). Betweenness may be normalised to [0,1] via EBC/[(N-1)(N-2)] Brandes's modified Dijkstra's algorithm; J Math Sociol (2001) 25:163-177. Mika Rubinov, UNSW, 2007 (last modified July 2008) """ if weighted: m = bct.to_gslm(cmatrix.tolist()) ebc, bc = bct.edge_betweenness_wei(m) ebcret = np.asarray(bct.from_gsl(ebc)) bcret = np.asarray(bct.from_gsl(bc)) bct.gsl_free(m) bct.gsl_free(ebc) bct.gsl_free(bc) return (ebcret, bcret) else: m = bct.to_gslm(cmatrix.tolist()) ebc, bc = bct.edge_betweenness_bin(m) ebcret = np.asarray(bct.from_gsl(ebc)) bcret = np.asarray(bct.from_gsl(bc)) bct.gsl_free(m) bct.gsl_free(ebc) bct.gsl_free(bc) return (ebcret, bcret)
def edge_betweenness(cmatrix, weighted): """ Edge betweenness centrality The fraction of all shortest paths in the network that traverse a given edge (link). This function outputs an edge betweenness matrix. Note that zero entries may correspond to an absence of an edge, or to an edge with betweenness of 0 -- a comparison with the connectivity matrix will clear up potential confusion. This function may also return nodal betweenness centrality. Parameters ---------- cmatrix : connection matrix, (distance matrix in weighted case) weighted : {True, False} Returns ------- weighted == False: EBC : edge betweenness centrality EBC, for a binary graph G BC : vertex betweenness centrality BC Betweenness may be normalised to [0,1] via EBC/[(N-1)(N-2)] Brandes's modified breadth-first search; J Math Sociol (2001) 25:163-177. Mika Rubinov, UNSW, 2007 (last modified July 2008). weighted == True: EBC : edge betweenness centrality EBC for weighted directed graph BC : vertex betweenness centrality BC The input matrix must be a mapping from weight to distance (eg. higher correlations may be interpreted as short distances - hence an inverse mapping is appropriate in that case). Betweenness may be normalised to [0,1] via EBC/[(N-1)(N-2)] Brandes's modified Dijkstra's algorithm; J Math Sociol (2001) 25:163-177. Mika Rubinov, UNSW, 2007 (last modified July 2008) """ if weighted: m = bct.to_gslm(cmatrix.tolist()) ebc,bc = bct.edge_betweenness_wei(m) ebcret = np.asarray(bct.from_gsl(ebc)) bcret = np.asarray(bct.from_gsl(bc)) bct.gsl_free(m) bct.gsl_free(ebc) bct.gsl_free(bc) return (ebcret, bcret) else: m = bct.to_gslm(cmatrix.tolist()) ebc,bc = bct.edge_betweenness_bin(m) ebcret = np.asarray(bct.from_gsl(ebc)) bcret = np.asarray(bct.from_gsl(bc)) bct.gsl_free(m) bct.gsl_free(ebc) bct.gsl_free(bc) return (ebcret, bcret)