# `Macaw.Frame.Keyboard.Graph`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/keyboard/graph.ex#L1)

A diagram's stops and edges as the keyboard follows them (spec/11 §5.7): what the
Frame writes on its keyboard element as `data-mw-graph`, so `FrameKeyboard` moves along
a diagram's edges on the client, one diagram's few nodes rather than a series' rows.

`new/1` reads a realized Frame's laid-out diagram tables, the same ones its summary
walks (spec/13 §7.3, spec/11 §2), and answers `nil` for a Frame that lays out no
diagram:

- **a graph** (a flowchart, a state, class or ER diagram, the `layered` step): a stop
  per node, in data order, and its edges by the edge table's `source` and `target`;
- **a sequence diagram** (`sequence`): a stop per message in time order, each message
  the edge to the next one;
- **a Gantt chart or a timeline** (`gantt`): a stop per task or event, bars then
  milestones in data order, and its dependencies as edges.

Each stop is `[item, x, y, name, text, out, in]`: the drawn item's key
(`<frame>.<layer>.<row>`), its center in the drawing's pixels (`null` where unplaced),
the `name` an edge move reads ("to Ship"), the `text` an in-order move reads, and its
outgoing and incoming edges, each `[stop, direction, label, edge]`: the stop at the
edge's other end, the bearing towards it in degrees in the drawing (clockwise from the
right, `null` where either end is unplaced or both are at one place), the edge's label
(`null` for none) and the edge's number. Everything is read from the tables' columns
(`Macaw.Frame.Columns`): the texts as a column each, the positions folded from their
packed buffers, and no row is made a map.

# `edge`

```elixir
@type edge() ::
  {non_neg_integer(), float() | nil, String.t() | nil, non_neg_integer()}
```

An edge from a stop: the stop at its other end, its bearing, label and number.

# `stop`

```elixir
@type stop() ::
  {String.t(), number() | nil, number() | nil, String.t(), String.t(), [edge()],
   [edge()]}
```

A stop: its item, position, name, readout, and outgoing and incoming edges.

# `t`

```elixir
@type t() :: %Macaw.Frame.Keyboard.Graph{
  edges: non_neg_integer(),
  none: {String.t(), String.t()},
  nouns: {String.t(), String.t() | nil},
  stops: [stop()],
  walk: String.t()
}
```

A diagram's walk: its kind, its stops, how many edges, and its words.

# `attrs`

```elixir
@spec attrs(term(), term()) :: [{String.t(), String.t()}]
```

The keyboard element's attribute of the walk, `[{"data-mw-graph", json}]`, `[]` for
no walk.

# `new`

```elixir
@spec new(term()) :: t() | nil
```

The walk of a realized Frame's diagram, or `nil` for a Frame that lays out none (or a
term that is no realized Frame).

# `payload`

```elixir
@spec payload(term(), term()) :: map() | nil
```

The walk as the hook reads it, under the Frame's `name`: `%{"walk", "intro", "out",
"in", "stops"}`, `intro` what focusing the Frame reads, `out` and `in` what a move
along no edge reads after the stop's text, `stops` each stop as a list. `nil` for no
walk.

---

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