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