package ocamlgraph

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Reads layout information from xdot ASTs

Simple layout types

type pos = float * float

2D coordinates

type bounding_box = pos * pos

upper-left and bottom-right corners

Layout informations are parsed from xdot files (dot files with graphviz layout).

Each node or edge layout thus contains several lists of drawing operations.

See http://www.graphviz.org/doc/info/output.html#d:xdot to understand the details of the layout informations.

type node_layout = {
  1. n_name : string;
    (*

    Dot label

    *)
  2. n_pos : pos;
    (*

    Center position

    *)
  3. n_bbox : bounding_box;
    (*

    Bounding box

    *)
  4. n_draw : XDotDraw.operation list;
    (*

    Shape drawing

    *)
  5. n_ldraw : XDotDraw.operation list;
    (*

    Label drawing

    *)
}

Each node has at least a position and a bounding box.

type cluster_layout = {
  1. c_pos : pos;
  2. c_bbox : bounding_box;
  3. c_draw : XDotDraw.operation list;
  4. c_ldraw : XDotDraw.operation list;
}
type edge_layout = {
  1. e_draw : XDotDraw.operation list;
    (*

    Shapes and curves

    *)
  2. e_ldraw : XDotDraw.operation list;
    (*

    Label drawing

    *)
  3. e_hdraw : XDotDraw.operation list;
    (*

    Head arrowhead drawing

    *)
  4. e_tdraw : XDotDraw.operation list;
    (*

    Tail arrowhead drawing

    *)
  5. e_hldraw : XDotDraw.operation list;
    (*

    Head label drawing

    *)
  6. e_tldraw : XDotDraw.operation list;
    (*

    Tail label drawing

    *)
}
val mk_node_layout : name:string -> pos:pos -> bbox:bounding_box -> draw:XDotDraw.operation list -> ldraw:XDotDraw.operation list -> node_layout

Creates a node layout

val mk_cluster_layout : pos:pos -> bbox:bounding_box -> draw:XDotDraw.operation list -> ldraw:XDotDraw.operation list -> cluster_layout

Creates a cluster layout

val mk_edge_layout : draw:XDotDraw.operation list -> ldraw:XDotDraw.operation list -> hdraw:XDotDraw.operation list -> tdraw:XDotDraw.operation list -> hldraw:XDotDraw.operation list -> tldraw:XDotDraw.operation list -> edge_layout

Creates an edge layout

Parsing and reading XDot

exception ParseError of string
module Make (G : Graphviz.GraphWithDotAttrs) : sig ... end

Instantiates a module which creates graph layouts from xdot files

Converts and reads various layout informations

val bounding_box : (float * float) -> float -> float -> bounding_box

bounding_box pos w h converts a bounding box of center pos, width w and height h from a Dot file to a pair of corners (lower left and upper right) in the world coordinate system.

  • parameter pos

    position of the center of the node

  • parameter w

    width of the node

  • parameter h

    height of the node

val read_bounding_box : string -> bounding_box
val read_node_layout : Dot_ast.node_id -> Dot_ast.attr list -> node_layout

Reads xdot layouts from the dot ast

val read_edge_layout : Dot_ast.attr list -> edge_layout
val read_cluster_layout : Dot_ast.attr list -> cluster_layout