예제 #1
0
파일: measures.py 프로젝트: omerch/pyconto
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)
예제 #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)
예제 #3
0
파일: bct.py 프로젝트: aestrivex/pyconto
def efficiency_global(*args):
  return _bct.efficiency_global(*args)
예제 #4
0
def efficiency_global(*args):
    return _bct.efficiency_global(*args)
예제 #5
0
파일: bct.py 프로젝트: aestrivex/pyconto
def efficiency_global(*args):
  """efficiency_global(gsl_matrix G) -> gsl_matrix"""
  return _bct.efficiency_global(*args)
예제 #6
0
파일: bct.py 프로젝트: omerch/pyconto
def efficiency_global(*args):
    """efficiency_global(gsl_matrix G) -> gsl_matrix"""
    return _bct.efficiency_global(*args)