find_path

openpnm.topotools.find_path(network, pore_pairs, weights=None)[source]

Find the shortest path between pairs of pores.

Parameters
  • network (GenericNetwork) – The Network object on which the search should be performed

  • pore_pairs (array_like) – An N x 2 array containing N pairs of pores for which the shortest path is sought.

  • weights (array_like, optional) – An Nt-long list of throat weights for the search. Typically this would be the throat lengths, but could also be used to represent the phase configuration. If no weights are given then the standard topological connections of the Network are used.

Returns

  • A dictionary containing both the pores and throats that define the

  • shortest path connecting each pair of input pores.

Notes

The shortest path is found using Dijkstra’s algorithm included in the scipy.sparse.csgraph module

TODO: The returned throat path contains the correct values, but not necessarily in the true order

Examples

>>> import openpnm as op
>>> pn = op.network.Cubic(shape=[3, 3, 3])
>>> a = op.topotools.find_path(network=pn, pore_pairs=[[0, 4], [0, 10]])
>>> a['pores']
[array([0, 1, 4]), array([ 0,  1, 10])]
>>> a['throats']
[array([ 0, 19]), array([ 0, 37])]