context function 2: find-operators-between
find-operators-between:
description:
find-operators-between(ket1, ket2)
Use Dijkstra's algorithm to find the shortest path between ket1 and ket2
See: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Same as find-path-between(), except we instead return the operator sequence required to get from ket1 to ket2
examples:
-- learn a grid, then find a path:
learn-grid[10, 10]
find-operators-between(|grid: 0: 0>, |grid: 5: 6>)
|op: E> . |op: SE> . |op: SE> . |op: SE> . |op: SE> . |op: SE>
-- a quick demonstration that this is correct:
SE SE SE SE SE E |grid: 0: 0>
|grid: 5: 6>
-- find pathway through a friend network:
-- first define some friends:
friends |Fred> => |Jack> + |Harry> + |Ed> + |Mary> + |Rob> + |Patrick> + |Emma> + |Charlie>
friends |Sam> => |Charlie> + |George> + |Emma> + |Jack> + |Robert> + |Frank> + |Julie>
-- find inverse friends links:
find-inverse[friends]
-- find friend pathway from Fred to Sam:
find-operators-between(|Fred>, |Sam>)
|op: friends> . |op: inverse-friends>
-- find friend pathway from Fred to Julie:
find-operators-between(|Fred>, |Julie>)
|op: friends> . |op: inverse-friends> . |op: friends>
-- verify we reach Julie using this operator sequence:
friends inverse-friends friends |Fred>
11|Jack> + 8|Harry> + 8|Ed> + 8|Mary> + 8|Rob> + 8|Patrick> + 11|Emma> + 11|Charlie> + 3|George> + 3|Robert> + 3|Frank> + 3|Julie>
see also:
find-path-between, find-inverse
Home