Ejemplo n.º 1
0
def efficiency(cmatrix, local=False, edgetype='undirected', weighted=False):
    """ A measure similar to the clustering coefficient, based upon the
    calculation of the harmonic mean of neighbor-neighbor distances.
    For directed networks, this function works on the out-degree.
    
    A global efficiency matrix is the inverse of the distance matrix
    (with self-self distances set to 0). Calculating the global efficiency
    is advantageous over distance in disconnected networks:
    the efficiency between disconnected pairs of nodes is set to 0
    (the inverse of infinity), hence enabling the calculation of network
    wide averages (which become meaningless on distance matrices).

    Parameters
    ----------
    cmatrix : array_like
        Two dimensional connection/adjacency matrix
    
    edgetype : {'undirected'} 

    weighted : {False}


    Returns
    -------
    local == True:
    
        Eglob : outputs the inverse distance matrix: the mean of this
                matrix (excluding main diagonal) is equivalent to the global
                efficiency.
    
    local == False:
    
        Eloc : outputs individual nodal local efficiency.
               For directed networks, local efficiency works with the
               out-degree. 
               
               
    Reference: Latora and Marchiori, 2001, Phys Rev Lett 87:198701.
    
    Algebraic shortest path algorithm.
    
    Mika Rubinov, UNSW, 2008 (last modified September 2008).
    """
    if edgetype == 'undirected' and weighted == False:
        if local:
            m = bct.to_gslm(cmatrix.tolist())
            eloc = bct.efficiency_local(m)
            elocnp = bct.from_gsl(eloc)
            bct.gsl_free(m)
            bct.gsl_free(eloc)
            return np.asarray(elocnp)
        else:
            m = bct.to_gslm(cmatrix.tolist())
            eloc = bct.efficiency_global(m)
            elocnp = bct.from_gsl(eloc)
            bct.gsl_free(m)
            bct.gsl_free(eloc)
            return np.asarray(elocnp)
Ejemplo n.º 2
0
def efficiency(cmatrix, local = False, edgetype = 'undirected', weighted = False):
    """ A measure similar to the clustering coefficient, based upon the
    calculation of the harmonic mean of neighbor-neighbor distances.
    For directed networks, this function works on the out-degree.
    
    A global efficiency matrix is the inverse of the distance matrix
    (with self-self distances set to 0). Calculating the global efficiency
    is advantageous over distance in disconnected networks:
    the efficiency between disconnected pairs of nodes is set to 0
    (the inverse of infinity), hence enabling the calculation of network
    wide averages (which become meaningless on distance matrices).

    Parameters
    ----------
    cmatrix : array_like
        Two dimensional connection/adjacency matrix
    
    edgetype : {'undirected'} 

    weighted : {False}


    Returns
    -------
    local == True:
    
        Eglob : outputs the inverse distance matrix: the mean of this
                matrix (excluding main diagonal) is equivalent to the global
                efficiency.
    
    local == False:
    
        Eloc : outputs individual nodal local efficiency.
               For directed networks, local efficiency works with the
               out-degree. 
               
               
    Reference: Latora and Marchiori, 2001, Phys Rev Lett 87:198701.
    
    Algebraic shortest path algorithm.
    
    Mika Rubinov, UNSW, 2008 (last modified September 2008).
    """
    if edgetype == 'undirected' and weighted == False:
        if local:
            m = bct.to_gslm(cmatrix.tolist())
            eloc = bct.efficiency_local(m)
            elocnp = bct.from_gsl(eloc)
            bct.gsl_free(m)
            bct.gsl_free(eloc)
            return np.asarray(elocnp)
        else:
            m = bct.to_gslm(cmatrix.tolist())
            eloc = bct.efficiency_global(m)
            elocnp = bct.from_gsl(eloc)
            bct.gsl_free(m)
            bct.gsl_free(eloc)
            return np.asarray(elocnp)
Ejemplo n.º 3
0
def efficiency_local(*args):
  return _bct.efficiency_local(*args)
Ejemplo n.º 4
0
def efficiency_local(*args):
    return _bct.efficiency_local(*args)
Ejemplo n.º 5
0
def efficiency_local(*args):
  """efficiency_local(gsl_matrix G) -> gsl_vector"""
  return _bct.efficiency_local(*args)
Ejemplo n.º 6
0
def efficiency_local(*args):
    """efficiency_local(gsl_matrix G) -> gsl_vector"""
    return _bct.efficiency_local(*args)