示例#1
0
文件: bct.py 项目: aestrivex/pyconto
def degrees_dir(*args):
  return _bct.degrees_dir(*args)
示例#2
0
def degrees_dir(*args):
    return _bct.degrees_dir(*args)
示例#3
0
文件: bct.py 项目: aestrivex/pyconto
def degrees_dir(*args):
  """degrees_dir(gsl_matrix CIJ) -> gsl_vector"""
  return _bct.degrees_dir(*args)
示例#4
0
def degree(cmatrix, directed):
    """ In an undirected graph, the degree is the number of connections
    for individual nodes.
    
    In a directed graph, the indegree (outdegree) is the number of incoming
    (outgoing) connections for individual nodes.  The degree is the sum of
    indegree and outdegree.Connection weights are ignored.
    
    Parameters
    ----------  
    cmatrix : ndarray (N,N)
        Connection/Adjacency matrix
    directed : boolean
        Is the network directed?

    Returns
    -------
    directed == True:
        deg : ndarray
            Degree for all vertices
        deg_in : ndarray
            In-Degree for all vertices
        deg_out : ndarray
            Out-Degree for all vertices
    
        Computes the and degree (indegree + outdegree) for a
        directed binary matrix.  Weights are discarded.
    
        Note: Inputs of CIJ are assumed to be on the columns of the matrix.
    
        Olaf Sporns, Indiana University, 2002/2006/2008

    directed == False:
        deg : ndarray
            Degree for all vertices
        deg_in : ndarray
            In-Degree for all vertices
        deg_out : ndarray
            Out-Degree for all vertices
                
        Computes the degree for a nondirected binary matrix.  Weights are
        discarded.
    
        Olaf Sporns, Indiana University, 2002/2006/2008

    """
    if directed:
        m = bct.to_gslm(cmatrix.tolist())
        deg, deg_in, deg_out = bct.degrees_dir(m)
        rdeg = bct.from_gsl(deg)
        rdeg_in = bct.from_gsl(deg)
        rdeg_out = bct.from_gsl(deg)
        bct.gsl_free(m)
        bct.gsl_free(deg)
        bct.gsl_free(deg_in)
        bct.gsl_free(deg_out)
        return (rdeg, rdeg_in, rdeg_out)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        deg = bct.degrees_und(m)
        rdeg = bct.from_gsl(deg)
        bct.gsl_free(m)
        bct.gsl_free(deg)
        return rdeg
示例#5
0
文件: bct.py 项目: omerch/pyconto
def degrees_dir(*args):
    """degrees_dir(gsl_matrix CIJ) -> gsl_vector"""
    return _bct.degrees_dir(*args)
示例#6
0
def degree(cmatrix, directed):
    """ In an undirected graph, the degree is the number of connections
    for individual nodes.
    
    In a directed graph, the indegree (outdegree) is the number of incoming
    (outgoing) connections for individual nodes.  The degree is the sum of
    indegree and outdegree.Connection weights are ignored.
    
    Parameters
    ----------  
    cmatrix : ndarray (N,N)
        Connection/Adjacency matrix
    directed : boolean
        Is the network directed?

    Returns
    -------
    directed == True:
        deg : ndarray
            Degree for all vertices
        deg_in : ndarray
            In-Degree for all vertices
        deg_out : ndarray
            Out-Degree for all vertices
    
        Computes the and degree (indegree + outdegree) for a
        directed binary matrix.  Weights are discarded.
    
        Note: Inputs of CIJ are assumed to be on the columns of the matrix.
    
        Olaf Sporns, Indiana University, 2002/2006/2008

    directed == False:
        deg : ndarray
            Degree for all vertices
        deg_in : ndarray
            In-Degree for all vertices
        deg_out : ndarray
            Out-Degree for all vertices
                
        Computes the degree for a nondirected binary matrix.  Weights are
        discarded.
    
        Olaf Sporns, Indiana University, 2002/2006/2008

    """
    if directed:
        m = bct.to_gslm(cmatrix.tolist())
        deg, deg_in, deg_out = bct.degrees_dir(m)
        rdeg = bct.from_gsl(deg)
        rdeg_in = bct.from_gsl(deg)
        rdeg_out = bct.from_gsl(deg)
        bct.gsl_free(m)
        bct.gsl_free(deg)
        bct.gsl_free(deg_in)
        bct.gsl_free(deg_out)
        return (rdeg, rdeg_in, rdeg_out)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        deg = bct.degrees_und(m)
        rdeg = bct.from_gsl(deg)
        bct.gsl_free(m)
        bct.gsl_free(deg)
        return rdeg