Exemplo n.º 1
0
def betweenness(cmatrix, weighted=False):
    """ Betweenness centrality
    
    Only for directed networks.
    
    Parameters
    ----------
    cmatrix : connection/adjacency matrix
    
    weighted : {False, True}
    
    Returns
    -------
    
    weighted == True:

        BC : Betweenness centrality BC for weighted directed graph
        
        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 BC/[(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)
    
    weighted == False:
        
        BC : betweenness centrality BC, for a binary directed graph G
    
        Betweenness may be normalised to [0,1] via BC/[(N-1)(N-2)]
        
        Algorithm of Kintali, generalised to directed and disconnected graphs
        http://www.cc.gatech.edu/~kintali/papers/bc.pdf
        
        Mika Rubinov, UNSW, 2007 (last modified July 2008)
        
    """
    if weighted:
        m = bct.to_gslm(cmatrix.tolist())
        dist = bct.betweenness_wei(m)
        distnp = bct.from_gsl(dist)
        bct.gsl_free(m)
        bct.gsl_free(dist)
        return np.asarray(distnp)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        dist = bct.betweenness_bin(m)
        distnp = bct.from_gsl(dist)
        bct.gsl_free(m)
        bct.gsl_free(dist)
        return np.asarray(distnp)
Exemplo n.º 2
0
def betweenness(cmatrix, weighted = False):
    """ Betweenness centrality
    
    Only for directed networks.
    
    Parameters
    ----------
    cmatrix : connection/adjacency matrix
    
    weighted : {False, True}
    
    Returns
    -------
    
    weighted == True:

        BC : Betweenness centrality BC for weighted directed graph
        
        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 BC/[(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)
    
    weighted == False:
        
        BC : betweenness centrality BC, for a binary directed graph G
    
        Betweenness may be normalised to [0,1] via BC/[(N-1)(N-2)]
        
        Algorithm of Kintali, generalised to directed and disconnected graphs
        http://www.cc.gatech.edu/~kintali/papers/bc.pdf
        
        Mika Rubinov, UNSW, 2007 (last modified July 2008)
        
    """
    if weighted:
        m = bct.to_gslm(cmatrix.tolist())
        dist = bct.betweenness_wei(m)
        distnp = bct.from_gsl(dist)
        bct.gsl_free(m)
        bct.gsl_free(dist)
        return np.asarray(distnp)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        dist = bct.betweenness_bin(m)
        distnp = bct.from_gsl(dist)
        bct.gsl_free(m)
        bct.gsl_free(dist)
        return np.asarray(distnp)
Exemplo n.º 3
0
def betweenness_wei(*args):
  return _bct.betweenness_wei(*args)
Exemplo n.º 4
0
def betweenness_wei(*args):
    return _bct.betweenness_wei(*args)
Exemplo n.º 5
0
def betweenness_wei(*args):
  """betweenness_wei(gsl_matrix G) -> gsl_vector"""
  return _bct.betweenness_wei(*args)
Exemplo n.º 6
0
def betweenness_wei(*args):
    """betweenness_wei(gsl_matrix G) -> gsl_vector"""
    return _bct.betweenness_wei(*args)