package mlpost

  1. Overview
  2. Docs

Create and draw trees

This module provides high-level means for creating and drawing Trees

type t

The type of trees

type arrow_style =
  1. | Directed
    (*

    edges are directed and an arrow is drawn at the end of an edge

    *)
  2. | Undirected
    (*

    edges are undirected and no arrow is drawn

    *)

The style of arrows between nodes

type edge_style =
  1. | Straight
    (*

    edges are straight lines between nodes

    *)
  2. | Curve
    (*

    edges are curved lines between nodes

    *)
  3. | Square
    (*

    edges are straight lines and branch out from the sides of nodes

    *)
  4. | HalfSquare
    (*

    edges are straight lines and branch out from below nodes

    *)

There are several styles available for edges

val leaf : Box.t -> t

Creation

leaf b creates a leaf with Box b.

val node : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style -> ?edge_style:edge_style -> ?stroke:Color.t -> ?brush:Brush.t -> ?pen:Pen.t -> ?sep:Num.t -> Box.t -> t list -> t

node label children creates a node with label label and a list of children children. Default arrow_style is Directed. Default edge_style is Straight.

  • ls (level sep): vertical distance between levels. The default value is 1.0. A negative value draws the tree upward.
  • cs (children sep): horizontal distance between siblings. The default value is 0.2. Optional arguments are the same as in leaf.
val nodel : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style -> ?edge_style:edge_style -> ?stroke:Color.t -> ?brush:Brush.t -> ?pen:Pen.t -> ?sep:Num.t -> Box.t -> (t * (Command.position * Picture.t)) list -> t

Similar to node but with labels on edges. Labels are taken into account only when edge_style is Straight.

val bin : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style -> ?edge_style:edge_style -> ?stroke:Color.t -> ?brush:Brush.t -> ?pen:Pen.t -> ?sep:Num.t -> Box.t -> t -> t -> t

bin label l r creates a binary node with label label and children l and r. Optional arguments are the same as in leaf.

val to_box : t -> Box.t
val draw : ?debug:bool -> t -> Command.t
module Simple : sig ... end
OCaml

Innovation. Community. Security.