示例#1
0
def breadth(cmatrix, source):
    """ Breadth-first search tree
    
    Performs a breadth-first search starting at the source node.  Because C++
    indexing is zero-based, a value of 0 at branch(i) could mean either that
    node 0 precedes node i or that node i is unreachable.  Check distance(i)
    for GSL_POSINF to differentiate between these two cases.
 
    Parameters
    ----------
    cmatrix : connection matrix
    
    source : source vertex
    
    Returns
    -------
    distance : distance between 'source' and i'th vertex
               (0 for source vertex)
    branch : vertex that precedes i in the breadth-first search tree
             (-1 for source vertex)
            
    Note: breadth-first search tree does not contain all paths 
    (or all shortest paths), but allows the determination of at least one 
    path with minimum distance.
    the entire graph is explored, starting from source vertex 'source'
    
    Olaf Sporns, Indiana University, 2002/2007/2008
    """
    m = bct.to_gslm(cmatrix.tolist())
    str = bct.breadth(m, source)
    strnp = bct.from_gsl(str)
    bct.gsl_free(m)
    bct.gsl_free(str)
    return np.asarray(strnp)
示例#2
0
def breadth(cmatrix, source):
    """ Breadth-first search tree
    
    Performs a breadth-first search starting at the source node.  Because C++
    indexing is zero-based, a value of 0 at branch(i) could mean either that
    node 0 precedes node i or that node i is unreachable.  Check distance(i)
    for GSL_POSINF to differentiate between these two cases.
 
    Parameters
    ----------
    cmatrix : connection matrix
    
    source : source vertex
    
    Returns
    -------
    distance : distance between 'source' and i'th vertex
               (0 for source vertex)
    branch : vertex that precedes i in the breadth-first search tree
             (-1 for source vertex)
            
    Note: breadth-first search tree does not contain all paths 
    (or all shortest paths), but allows the determination of at least one 
    path with minimum distance.
    the entire graph is explored, starting from source vertex 'source'
    
    Olaf Sporns, Indiana University, 2002/2007/2008
    """
    m = bct.to_gslm(cmatrix.tolist())
    str = bct.breadth(m, source)
    strnp = bct.from_gsl(str)
    bct.gsl_free(m)
    bct.gsl_free(str)
    return np.asarray(strnp)
示例#3
0
文件: bct.py 项目: aestrivex/pyconto
def breadth(*args):
  return _bct.breadth(*args)
示例#4
0
def breadth(*args):
    return _bct.breadth(*args)
示例#5
0
文件: bct.py 项目: aestrivex/pyconto
def breadth(*args):
  """breadth(gsl_matrix CIJ, int source) -> gsl_vector"""
  return _bct.breadth(*args)
示例#6
0
文件: bct.py 项目: omerch/pyconto
def breadth(*args):
    """breadth(gsl_matrix CIJ, int source) -> gsl_vector"""
    return _bct.breadth(*args)