# `Diffo.Provider.Calculations.Traversal`
[🔗](https://github.com/diffo-dev/diffo/blob/v0.9.0/lib/diffo/provider/components/calculations/traversal.ex#L5)

Runtime graph walk for a normalised `via:` hop list.

Threads a set of instance ids through each hop in order, following one edge per hop:

- `:forward` — filter `source_id` in the current ids, collect `target_id`s.
- `:reverse` — filter `target_id` in the current ids, collect `source_id`s.

over `AssignmentRelationship` (`:assignment` hops) or — for `:relationship` hops — **both**
`DefinedSimpleRelationship` and the general `Relationship` (#222), since an edge is stored
as one or the other and traversal is meaningful over either. A hop may fan out (reach many
instances) or fan in (several intermediates reach the same instance); ids are de-duplicated
between hops so a node reached by multiple paths is visited once.

Hops are the canonical form produced by `Diffo.Provider.Extension.Traversal.normalize/2`:
`{:forward | :reverse, :assignment | :relationship, selector}`. Built so
`inherited_place` / `inherited_party` can adopt the same grammar later.

# `walk`

Walks `hops` from `start_id`, returning the de-duplicated list of final instance ids.

An empty `hops` list returns `[start_id]`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
