Module Imandrakit.Dot

Pretty printing in the DOT (graphviz) format.

Example (print divisors from 42):

let open Dot in
with_out "/tmp/truc.dot"
  (fun out ->
     pp ~attrs_v:(fun i -> [`Label (string_of_int i)]) ~graph:divisors_graph out 42
  )
type ('v, 'e) graph = 'v -> ('e * 'v) Iter.t

Directed graph with vertices of type 'v and edges labeled with e'

type attribute = [
  1. | `Color of string
  2. | `Shape of string
  3. | `Weight of int
  4. | `Style of string
  5. | `Label of string
  6. | `Other of string * string
]

Dot attribute

val pp : tbl:(module Stdlib.Hashtbl.S with type key = 'v) -> ?attrs_v:('v -> attribute list) -> ?attrs_e:('e -> attribute list) -> ?name:string -> graph:('v, 'e) graph -> 'v Imandrakit_common.Fmt.printer

Print the graph, starting from given vertex, on the formatter.

  • parameter attrs_v

    attributes for vertices.

  • parameter attrs_e

    attributes for edges.

  • parameter name

    name of the graph.

val pp_all : tbl:(module Stdlib.Hashtbl.S with type key = 'v) -> ?attrs_v:('v -> attribute list) -> ?attrs_e:('e -> attribute list) -> ?name:string -> graph:('v, 'e) graph -> 'v Iter.t Imandrakit_common.Fmt.printer

Same as pp but starting from several vertices, not just one.

val with_out : string -> (Stdlib.Format.formatter -> 'a) -> 'a

Shortcut to open a file and write to it.

val escape_dot : string -> string

Escaping for graphviz labels

val default_style_dot : string

Default style for labels in graphviz