Exemplo n.º 1
0
def density(cmatrix, edgetype):
    """ Density is the proportion of the number of present connections in the
    network, to the maximum possible number of connections.  Connection
    weights are ignored.
    
    Parameters
    ----------
    
    cmatrix : connection/adjacency matrix
    
    Returns
    -------
    
    edgetype == 'undirected':

        kden : connection density, number of connections present out of all
               possible (N^2-N)

        Note: Assumes that cmatrix is undirected and that there are no
              self-connections.
        Note: Function always returns average binary density, regardless
              of weights.
        
        Olaf Sporns, Indiana University, 2002/2007/2008

        Modification history:
        2009-10: K fixed to sum over one half of cmatrix [Tony Herdman, SFU]

    edgetype == 'directed'

        kden : connection density, number of connections present out of all
               possible (N^2-N)
    
        Note: Assumes that cmatrix is directed and that there are no
              self-connections.
        Note: Function always returns average binary density, regardless of
              weights.
    
        Olaf Sporns, Indiana University, 2002/2007/2008

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        val = bct.density_und(m)
        bct.gsl_free(m)
        return val
    elif edgetype == 'directed':
        m = bct.to_gslm(cmatrix.tolist())
        val = bct.density_dir(m)
        bct.gsl_free(m)
        return val
Exemplo n.º 2
0
def density(cmatrix, edgetype):
    """ Density is the proportion of the number of present connections in the
    network, to the maximum possible number of connections.  Connection
    weights are ignored.
    
    Parameters
    ----------
    
    cmatrix : connection/adjacency matrix
    
    Returns
    -------
    
    edgetype == 'undirected':

        kden : connection density, number of connections present out of all
               possible (N^2-N)

        Note: Assumes that cmatrix is undirected and that there are no
              self-connections.
        Note: Function always returns average binary density, regardless
              of weights.
        
        Olaf Sporns, Indiana University, 2002/2007/2008

        Modification history:
        2009-10: K fixed to sum over one half of cmatrix [Tony Herdman, SFU]

    edgetype == 'directed'

        kden : connection density, number of connections present out of all
               possible (N^2-N)
    
        Note: Assumes that cmatrix is directed and that there are no
              self-connections.
        Note: Function always returns average binary density, regardless of
              weights.
    
        Olaf Sporns, Indiana University, 2002/2007/2008

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        val =  bct.density_und(m)
        bct.gsl_free(m)
        return val
    elif edgetype == 'directed':
        m = bct.to_gslm(cmatrix.tolist())
        val = bct.density_dir(m)
        bct.gsl_free(m)
        return val
Exemplo n.º 3
0
def density_und(*args):
  return _bct.density_und(*args)
Exemplo n.º 4
0
def density_und(*args):
    return _bct.density_und(*args)
Exemplo n.º 5
0
def density_und(*args):
  """density_und(gsl_matrix CIJ) -> double"""
  return _bct.density_und(*args)
Exemplo n.º 6
0
def density_und(*args):
    """density_und(gsl_matrix CIJ) -> double"""
    return _bct.density_und(*args)