Ejemplo n.º 1
0
def assortativity(cmatrix, directed=False):
    """ Assortativity coefficient. Essentially, the assortativity is a
    correlation coefficient for the degrees of linked nodes. A positive
    assortativity coefficient indicates that nodes tend to link to other
    nodes with the same or similar degree.
    
    The function accepts weighted networks, but the connection weights
    are ignored.
    
    Parameters
    ----------
    cmatrix : ndarray (N,N)
        Connection/Adjacency matrix
    directed : boolean
        Is the network directed?
   
    Returns
    -------
    r : array_like
        Assortativity
   
    Computed after Newman (2003)
    
    Note
    ----
    Weights are discarded, no edges on main diagonal.
    
    Olaf Sporns, Indiana University, 2007/2008
    Vassilis Tsiaras, University of Crete, 2009
    """
    if not directed:
        m = bct.to_gslm(cmatrix.tolist())
        ass = bct.assortativity_und(m)
        r = bct.from_gsl(ass)
        if np.isnan(ass):
            return 0
        bct.gsl_free(m)
        bct.gsl_free(ass)
        return r
    else:
        m = bct.to_gslm(cmatrix.tolist())
        ass = bct.assortativity_dir(m)
        if np.isnan(ass):
            return 0
        r = bct.from_gsl(ass)
        bct.gsl_free(m)
        bct.gsl_free(ass)
        return r
Ejemplo n.º 2
0
def assortativity(cmatrix, directed = False):
    """ Assortativity coefficient. Essentially, the assortativity is a
    correlation coefficient for the degrees of linked nodes. A positive
    assortativity coefficient indicates that nodes tend to link to other
    nodes with the same or similar degree.
    
    The function accepts weighted networks, but the connection weights
    are ignored.
    
    Parameters
    ----------
    cmatrix : ndarray (N,N)
        Connection/Adjacency matrix
    directed : boolean
        Is the network directed?
   
    Returns
    -------
    r : array_like
        Assortativity
   
    Computed after Newman (2003)
    
    Note
    ----
    Weights are discarded, no edges on main diagonal.
    
    Olaf Sporns, Indiana University, 2007/2008
    Vassilis Tsiaras, University of Crete, 2009
    """
    if not directed:
        m = bct.to_gslm(cmatrix.tolist())
        ass = bct.assortativity_und(m)
        r = bct.from_gsl(ass)
        if np.isnan(ass):
            return 0
        bct.gsl_free(m)
        bct.gsl_free(ass)
        return r
    else:
        m = bct.to_gslm(cmatrix.tolist())
        ass = bct.assortativity_dir(m)
        if np.isnan(ass):
            return 0
        r = bct.from_gsl(ass)
        bct.gsl_free(m)
        bct.gsl_free(ass)
        return r
Ejemplo n.º 3
0
def assortativity_und(*args):
  return _bct.assortativity_und(*args)
Ejemplo n.º 4
0
def assortativity_und(*args):
    return _bct.assortativity_und(*args)
Ejemplo n.º 5
0
def assortativity_und(*args):
  """assortativity_und(gsl_matrix CIJ) -> double"""
  return _bct.assortativity_und(*args)
Ejemplo n.º 6
0
def assortativity_und(*args):
    """assortativity_und(gsl_matrix CIJ) -> double"""
    return _bct.assortativity_und(*args)