Swimlanes (spec/08 §13): a layered graph (Macaw.Draw.Layout.Layered) banded into lanes,
an activity diagram or a process map whose nodes each belong to one lane.
iex> alias Macaw.Draw.Layout.{Graph, Swimlanes}
iex> {:ok, graph} = Graph.new(["a"], ["b"], nil, nil, 1)
iex> {:ok, lanes} = Swimlanes.new()
iex> {:ok, result} =
...> Swimlanes.generate(lanes, graph, [{40, 20}, {40, 20}],
...> [%{id: "ops", label: {30, 10}}, %{id: "dev", label: {30, 10}}], lane_of: ["ops", "dev"])
iex> Enum.map(result.lanes, & &1.id)
["ops", "dev"]The algorithm (§13.2, spec/08 decision 10):
- Ranks along the flow axis are the layered layout's over the whole graph, so a flow's order is the graph's whatever lanes its steps are in.
- Order within a rank is grouped by lane: each rank's nodes are ordered first by
their lane, then by crossing reduction within one lane's group. A dummy of an edge from
lane
ato lanebisa's up to the middle of the edge's span andb's after it, so a cross-lane edge changes lanes once. - Across the flow, each lane's nodes are placed by Brandes–Köpf over that lane alone,
offset into the lane's band; a band is
max(lane_min, extent + 2 · lane_pad)thick, the lanes stacked in orderlane_sepapart, and the flow starts afterheader. - Routing is the layered layout's,
:orthogonalby default, so a route crosses a lane boundary perpendicularly.
Options (§13.1): every option of Layered with direction one of directions/0
(:lr, lanes stacked top to bottom and flow left to right, the default; or :tb) and
routing defaulting to :orthogonal, plus lane_sep (0), lane_pad (16),
lane_min (60) and header (30), each a non-negative number.
Summary
Functions
The columns of a swimlane drawing (§13.3): :nodes and :edges as Layered.columns/2's,
and :lanes, one row per lane in order: "row" (nil), "id", "x0", "y0", "x1",
"y1" (the band), "label_x", "label_y" (its label's center in the header).
The swimlanes' directions: [:lr, :tb].
The swimlane drawing of graph (§13.1): sizes as Layered.generate/4's, lanes the
ordered %{id, label: {w, h}}, and opts Layered's labels: and min_lengths: with
lane_of:, the lane id of each node in node order (required).
The layout of opts (§13.1): {:ok, swimlanes} or {:error, faults}.
Types
@type t() :: %Macaw.Draw.Layout.Swimlanes{ align: :balanced | :ul | :ur | :dl | :dr, crossing_passes: pos_integer(), direction: :lr | :tb, edge_sep: number(), header: number(), lane_min: number(), lane_pad: number(), lane_sep: number(), margin: number(), node_sep: number(), rank_align: :center | :start | :end, rank_sep: number(), ranker: :network_simplex | :longest_path, routing: :orthogonal | :spline | :polyline, simplex_pivots: pos_integer() | nil }
Functions
@spec columns(Macaw.Draw.Layout.Swimlanes.Result.t(), atom() | String.t()) :: %{required(String.t()) => [term()]} | Macaw.Draw.Layout.error()
The columns of a swimlane drawing (§13.3): :nodes and :edges as Layered.columns/2's,
and :lanes, one row per lane in order: "row" (nil), "id", "x0", "y0", "x1",
"y1" (the band), "label_x", "label_y" (its label's center in the header).
@spec directions() :: [atom()]
The swimlanes' directions: [:lr, :tb].
@spec generate( t(), Macaw.Draw.Layout.Graph.t(), [{number(), number()}], [map()], keyword() | map() ) :: {:ok, Macaw.Draw.Layout.Swimlanes.Result.t()} | Macaw.Draw.Layout.error()
The swimlane drawing of graph (§13.1): sizes as Layered.generate/4's, lanes the
ordered %{id, label: {w, h}}, and opts Layered's labels: and min_lengths: with
lane_of:, the lane id of each node in node order (required).
A node of no listed lane is {[:lane_of, i], {:unknown_lane, id}}, a lane that is no
%{id, label} {[:lanes, i], {:type, :lane}}, a lane id given twice
{[:lanes, i], {:duplicate, id}}; the sizes and edge options fault as the layered
layout's.
@spec new() :: {:ok, t()}
new/1 with every option at its default.
@spec new(keyword() | map()) :: {:ok, t()} | Macaw.Draw.Layout.error()
The layout of opts (§13.1): {:ok, swimlanes} or {:error, faults}.