Macaw.Draw.Layout.Cluster (macaw_draw v0.1.0)

Copy Markdown View Source

The dendrogram: a node-link diagram whose leaves all sit at one depth (spec/08 §3.3).

iex> alias Macaw.Draw.Layout.{Cluster, Hierarchy}
iex> {:ok, root, []} = Hierarchy.stratify(~w(r a b a1), [nil, "r", "r", "a"], [])
iex> {:ok, cluster} = Cluster.new()
iex> cluster |> Cluster.generate(root) |> Hierarchy.leaves() |> Enum.map(&{&1.x, &1.y})
[{0, 2}, {2, 2}]

generate/2 places every leaf first, left to right in pre-order, at x = 0, s1, s1 + s2, …, each s being separation.(leaf, previous_leaf); every internal node at the midpoint of its first and last child. y is root.height for every leaf and the depth for every internal node. The options and their scaling are the tree's (Macaw.Draw.Layout.Tree, §3.1). This is visualize's Visualize.Layout.Cluster, its setters replaced by new/1.

Summary

Functions

The columns of a laid-out cluster, as the tree's (§3.5): :nodes with "x", "y", or :links with shape: and orientation:.

Every node of root positioned as a dendrogram, then scaled (§3.3). Leaves are matched to their positions by {data, depth}; with stratify/3's rows as data no two share one.

new/1 with every option at its default.

The layout of opts, the tree's options (§3.1): {:ok, cluster} or {:error, faults}.

Types

t()

@type t() :: %Macaw.Draw.Layout.Cluster{
  node_size: {number(), number()} | nil,
  separation: (Macaw.Draw.Layout.Hierarchy.t(),
               Macaw.Draw.Layout.Hierarchy.t() ->
                 number()),
  size: {number(), number()} | nil
}

Functions

columns(root, output, opts)

@spec columns(Macaw.Draw.Layout.Hierarchy.t(), atom() | String.t(), keyword()) ::
  %{required(String.t()) => [term()]} | Macaw.Draw.Layout.error()

The columns of a laid-out cluster, as the tree's (§3.5): :nodes with "x", "y", or :links with shape: and orientation:.

generate(cluster, root)

Every node of root positioned as a dendrogram, then scaled (§3.3). Leaves are matched to their positions by {data, depth}; with stratify/3's rows as data no two share one.

new()

@spec new() :: {:ok, t()}

new/1 with every option at its default.

new(opts)

@spec new(keyword() | map()) :: {:ok, t()} | Macaw.Draw.Layout.error()

The layout of opts, the tree's options (§3.1): {:ok, cluster} or {:error, faults}.