brainconn.distance.findpaths

findpaths(CIJ, qmax, sources, savepths=False)[source]

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 nodes, up to a specified length. Warning: very memory-intensive.

Parameters:
  • CIJ (NxN numpy.ndarray) – binary directed/undirected connection matrix
  • qmax (int) – maximal path length
  • sources (Nx1 numpy.ndarray) – source units from which paths are grown
  • savepths (bool) – True if all paths are to be collected and returned. This functionality is currently not enabled.
Returns:

  • Pq (NxNxQ numpy.ndarray) – Path matrix with P[i,j,jq] = number of paths from i to j with length q
  • tpath (int) – total number of paths found
  • plq (Qx1 numpy.ndarray) – path length distribution as a function of q
  • qstop (int) – path length at which findpaths is stopped
  • allpths (None) – a matrix containing all paths up to qmax. This function is extremely complicated and reimplementing it in bctpy is not straightforward.
  • util (NxQ numpy.ndarray) – node use index

Notes

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 certain that this algorithm is rather inefficient - suggestions for improvements are welcome.