Example #1
0
def findpaths(*args):
  return _bct.findpaths(*args)
Example #2
0
def findpaths(*args):
    return _bct.findpaths(*args)
Example #3
0
def findpaths(*args):
  """findpaths(gsl_matrix CIJ, gsl_vector sources, int qmax) -> std::vector<(p.gsl_matrix)>"""
  return _bct.findpaths(*args)
Example #4
0
def findpaths(cmatrix, sources, qmax):
    """ Paths are sequences of linked nodes, that never visit a single
    node more than once. This function finds all paths that start at a
    set of source vertices, up to a specified length. Warning: very
    memory-intensive.
    
    C++ Comment
     Finds paths from a set of source nodes up to a given length.  Note that
     there is no savepths argument; if all paths are desired, pass a valid
     pointer as he allpths argument.  There is also no tpath argument as its
     value may overflow a C++ long.  Since 0 is a valid node index in C++, -1
     is used as the "filler" value in allpths rather than 0 as in MATLAB. 
     Pq (the main return), plq, and util are indexed by path length.
     They therefore have (qmax + 1) elements and contain no valid data
     at index 0.
 
    function [Pq,tpath,plq,qstop,allpths,util] = 
        findpaths(CIJ,sources,qmax,savepths)

    Parameters
    ----------
    cmatrix : connection/adjacency matrix
    qmax : maximal path length
    sources : source units from which paths are grown
    savepths : set to 1 if all paths are to be collected in
               'allpths'
               
     Returns
     -------
    Pq : 3D matrix, with P(i,j,q) = number of paths from
         'i' to 'j' of length 'q'.
         
    Not returned by the C++ function:
    tpath      total number of paths found (lengths 1 to 'qmax')
    plq        path length distribution as a function of 'q'
    qstop      path length at which 'findpaths' is stopped
    allpths    a matrix containing all paths up to 'qmax'
    util       node use index

    Note that Pq[:,:,N] can only carry entries on the diagonal, as all "legal"
    paths of length N-1 must terminate.  Cycles of length N are possible, with
    all vertices visited exactly once (except for source and target).
    'qmax = N' can wreak havoc (due to memory problems).
    
    Note: Weights are discarded.
    Note: I am fairly certain that this algorithm is rather inefficient -
    suggestions for improvements are welcome.
    
    Olaf Sporns, Indiana University, 2002/2007/2008

    """
    # XXX: work on docstring
    m = bct.to_gslm(cmatrix.tolist())
    cil = bct.to_gslv(sources.tolist())
    pq, plq, qstop, allpths, util = bct.findpaths(m, cil, qmax)
    pqret = bct.from_gsl(pq)
    print pqret[0]
    print np.asarray(pqret[1])
    print plq
    print qstop
    print allpths
    print util
    bct.gsl_free(m)
    bct.gsl_free(pq)
    bct.gsl_free(plq)
    bct.gsl_free(allpths)
    bct.gsl_free(util)
    #logging.error("What to do with std::vector<gsl_matrix*> ??")
    return
Example #5
0
def findpaths(*args):
    """findpaths(gsl_matrix CIJ, gsl_vector sources, int qmax) -> std::vector<(p.gsl_matrix)>"""
    return _bct.findpaths(*args)
Example #6
0
def findpaths(cmatrix, sources, qmax):
    """ Paths are sequences of linked nodes, that never visit a single
    node more than once. This function finds all paths that start at a
    set of source vertices, up to a specified length. Warning: very
    memory-intensive.
    
    C++ Comment
     Finds paths from a set of source nodes up to a given length.  Note that
     there is no savepths argument; if all paths are desired, pass a valid
     pointer as he allpths argument.  There is also no tpath argument as its
     value may overflow a C++ long.  Since 0 is a valid node index in C++, -1
     is used as the "filler" value in allpths rather than 0 as in MATLAB. 
     Pq (the main return), plq, and util are indexed by path length.
     They therefore have (qmax + 1) elements and contain no valid data
     at index 0.
 
    function [Pq,tpath,plq,qstop,allpths,util] = 
        findpaths(CIJ,sources,qmax,savepths)

    Parameters
    ----------
    cmatrix : connection/adjacency matrix
    qmax : maximal path length
    sources : source units from which paths are grown
    savepths : set to 1 if all paths are to be collected in
               'allpths'
               
     Returns
     -------
    Pq : 3D matrix, with P(i,j,q) = number of paths from
         'i' to 'j' of length 'q'.
         
    Not returned by the C++ function:
    tpath      total number of paths found (lengths 1 to 'qmax')
    plq        path length distribution as a function of 'q'
    qstop      path length at which 'findpaths' is stopped
    allpths    a matrix containing all paths up to 'qmax'
    util       node use index

    Note that Pq[:,:,N] can only carry entries on the diagonal, as all "legal"
    paths of length N-1 must terminate.  Cycles of length N are possible, with
    all vertices visited exactly once (except for source and target).
    'qmax = N' can wreak havoc (due to memory problems).
    
    Note: Weights are discarded.
    Note: I am fairly certain that this algorithm is rather inefficient -
    suggestions for improvements are welcome.
    
    Olaf Sporns, Indiana University, 2002/2007/2008

    """
    # XXX: work on docstring
    m = bct.to_gslm(cmatrix.tolist())
    cil = bct.to_gslv(sources.tolist())
    pq, plq, qstop, allpths, util = bct.findpaths(m, cil, qmax)
    pqret = bct.from_gsl(pq)
    print pqret[0]
    print np.asarray(pqret[1])
    print plq
    print qstop
    print allpths
    print util
    bct.gsl_free(m)
    bct.gsl_free(pq)
    bct.gsl_free(plq)
    bct.gsl_free(allpths)
    bct.gsl_free(util)
    #logging.error("What to do with std::vector<gsl_matrix*> ??")
    return