Esempio n. 1
0
def modularity(cmatrix, edgetype):
    """ Community detection via optimization of modularity
    
    Parameters
    ----------
    cmatrix : adjacency or weights matrix
    edgetype : {'undirected', 'directed'}
    
    Returns
    -------
    edgetype == 'undirected':

        Ci : community structure Ci
        Q : maximized modularity Q.

        Algorithm: Newman's spectral optimization method:
        References: Newman (2006) -- Phys Rev E 74:036104; PNAS 23:8577-8582.
        
        Mika Rubinov, UNSW
        
        Modification History:
        Jul 2008: Original
        Oct 2008: Positive eigenvalues are now insufficient for division
                  (Jonathan Power, WUSTL)
        Dec 2008: Fine-tuning is now consistent with Newman's description
                  (Jonathan Power)
        Dec 2008: Fine-tuning is now vectorized (Mika Rubinov)
    
    edgetype == 'directed':
    
        Ci : community structure Ci
        Q : maximized modularity Q.
    
        Algorithm: Newman's spectral optimization method, generalized to
                   directed networks.
        Reference: Leicht and Newman (2008) Phys Rev Lett.
        
        Mika Rubinov, UNSW
        
        Modification History:
        Jul 2008: Original
        Oct 2008: Positive eigenvalues are now insufficient for division
                  (Jonathan Power, WUSTL)
        Dec 2008: Fine-tuning is now consistent with Newman's description
                  (Jonathan Power)
        Dec 2008: Fine-tuning is now vectorized (Mika Rubinov)

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.modularity_und(m)
        bct.gsl_free(m)
        return strr
    else:
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.modularity_dir(m)
        bct.gsl_free(m)
        return strr
Esempio n. 2
0
def modularity(cmatrix, edgetype):
    """ Community detection via optimization of modularity
    
    Parameters
    ----------
    cmatrix : adjacency or weights matrix
    edgetype : {'undirected', 'directed'}
    
    Returns
    -------
    edgetype == 'undirected':

        Ci : community structure Ci
        Q : maximized modularity Q.

        Algorithm: Newman's spectral optimization method:
        References: Newman (2006) -- Phys Rev E 74:036104; PNAS 23:8577-8582.
        
        Mika Rubinov, UNSW
        
        Modification History:
        Jul 2008: Original
        Oct 2008: Positive eigenvalues are now insufficient for division
                  (Jonathan Power, WUSTL)
        Dec 2008: Fine-tuning is now consistent with Newman's description
                  (Jonathan Power)
        Dec 2008: Fine-tuning is now vectorized (Mika Rubinov)
    
    edgetype == 'directed':
    
        Ci : community structure Ci
        Q : maximized modularity Q.
    
        Algorithm: Newman's spectral optimization method, generalized to
                   directed networks.
        Reference: Leicht and Newman (2008) Phys Rev Lett.
        
        Mika Rubinov, UNSW
        
        Modification History:
        Jul 2008: Original
        Oct 2008: Positive eigenvalues are now insufficient for division
                  (Jonathan Power, WUSTL)
        Dec 2008: Fine-tuning is now consistent with Newman's description
                  (Jonathan Power)
        Dec 2008: Fine-tuning is now vectorized (Mika Rubinov)

    """
    if edgetype == 'undirected':
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.modularity_und(m)
        bct.gsl_free(m)
        return strr
    else:
        m = bct.to_gslm(cmatrix.tolist())
        strr = bct.modularity_dir(m)
        bct.gsl_free(m)
        return strr
Esempio n. 3
0
def modularity_dir(*args):
  return _bct.modularity_dir(*args)
Esempio n. 4
0
def modularity_dir(*args):
    return _bct.modularity_dir(*args)
Esempio n. 5
0
def modularity_dir(*args):
  """modularity_dir(gsl_matrix A) -> double"""
  return _bct.modularity_dir(*args)
Esempio n. 6
0
def modularity_dir(*args):
    """modularity_dir(gsl_matrix A) -> double"""
    return _bct.modularity_dir(*args)