Example #1
0
def strengths(cmatrix, edgetype):
    """ Computes strength for an undirected or directed graph.
    
    Strength is the sum of all connection weights for individual nodes.

    In a directed graph, instrength (outstrength) is the sum of incoming
    (outgoing) connection weights for individual nodes. The strength is the
    sum of instrength and outstrength.
    

    Parameters
    ----------

    cmatrix : connection/adjacency matrix
    
    
    Returns
    -------
    
    edgetype == 'undirected'
    
        str : strength for all vertices
    
    edgetype == 'directed
    
        str : strength for all vertices (indegree + outdegree)

%         is   = instrength for all vertices
%         os   = outstrength for all vertices

    Reference: Barrat et al. (2004). Contributor: OS.

    Olaf Sporns, Indiana University, 2007/2008

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.strengths_und(m)
        strnp = bct.from_gsl(strr)
        bct.gsl_free(m)
        bct.gsl_free(strr)
        return np.asarray(strnp)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.strengths_dir(m)
        strnp = bct.from_gsl(strr)
        bct.gsl_free(m)
        bct.gsl_free(strr)
        return np.asarray(strnp)
Example #2
0
def strengths(cmatrix, edgetype):
    """ Computes strength for an undirected or directed graph.
    
    Strength is the sum of all connection weights for individual nodes.

    In a directed graph, instrength (outstrength) is the sum of incoming
    (outgoing) connection weights for individual nodes. The strength is the
    sum of instrength and outstrength.
    

    Parameters
    ----------

    cmatrix : connection/adjacency matrix
    
    
    Returns
    -------
    
    edgetype == 'undirected'
    
        str : strength for all vertices
    
    edgetype == 'directed
    
        str : strength for all vertices (indegree + outdegree)

%         is   = instrength for all vertices
%         os   = outstrength for all vertices

    Reference: Barrat et al. (2004). Contributor: OS.

    Olaf Sporns, Indiana University, 2007/2008

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.strengths_und(m)
        strnp = bct.from_gsl(strr)
        bct.gsl_free(m)
        bct.gsl_free(strr)
        return np.asarray(strnp)
    else:
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.strengths_dir(m)
        strnp = bct.from_gsl(strr)
        bct.gsl_free(m)
        bct.gsl_free(strr)
        return np.asarray(strnp)
Example #3
0
def strengths_und(*args):
  return _bct.strengths_und(*args)
Example #4
0
def strengths_und(*args):
    return _bct.strengths_und(*args)
Example #5
0
def strengths_und(*args):
  """strengths_und(gsl_matrix CIJ) -> gsl_vector"""
  return _bct.strengths_und(*args)
Example #6
0
def strengths_und(*args):
    """strengths_und(gsl_matrix CIJ) -> gsl_vector"""
    return _bct.strengths_und(*args)