Up

module Graphviz

: sig

Interface with GraphViz

This module provides a basic interface with dot and neato, two programs of the GraphViz toolbox. These tools are available at the following URLs:

Common stuff

Because the neato and dot engines present a lot of common points - in particular in the graph description language, large parts of the code is shared. The CommonAttributes module defines attributes of graphs, vertices and edges that are understood by the two engines. Then module DotAttributes and NeatoAttributes define attributes specific to dot and neato respectively.

Common types and signatures

#
type color = int
#
type color_with_transparency = int32

The two least significant bytes encode the transparency information; the six most signification are the standard RGB color

#
val color_to_color_with_transparency : color -> color_with_transparency
#
type arrow_style = [
| `None
| `Normal
| `Inv
| `Dot
| `Odot
| `Invdot
| `Invodot
]
#
module type ATTRIBUTES = sig

The ATTRIBUTES module type defines the interface for the engines.

#
type graph

Attributes of graphs.

#
type vertex

Attributes of vertices.

#
type edge

Attributes of edges.

#
type subgraph = {
# sg_name
: string;(*Box name.*)
# sg_attributes
: vertex list;(*Box attributes.*)
# sg_parent
: string option;(*Nested subgraphs.*)
}

Attributes of (optional) boxes around vertices.

end

Common attributes

#
module CommonAttributes : sig

The CommonAttributes module defines attributes for graphs, vertices and edges that are available in the two engines, dot and neato.

#
type graph = [
| `Center of bool
| `Fontcolor of color
| `Fontname of string
| `Fontsize of int
| `Label of string
| `Orientation of [
| `Portrait
| `Landscape
]
| `Page of float * float
| `Pagedir of [
| `TopToBottom
| `LeftToRight
]
| `Size of float * float
| `OrderingOut
]

Attributes of graphs.

#
type vertex = [
| `Color of color
| `ColorWithTransparency of color_with_transparency
| `Fontcolor of color
| `Fontname of string
| `Fontsize of int
| `Height of float
| `Label of string
| `Orientation of float
| `Penwidth of float
| `Peripheries of int
| `Regular of bool
| `Shape of [
| `Ellipse
| `Box
| `Circle
| `Doublecircle
| `Diamond
| `Plaintext
| `Record
| `Polygon of int * float
]
| `Style of [
| `Rounded
| `Filled
| `Solid
| `Dashed
| `Dotted
| `Bold
| `Invis
]
| `Width of float
]

Attributes of vertices.

#
type edge = [
| `Color of color
| `ColorWithTransparency of color_with_transparency
| `Decorate of bool
| `Dir of [
| `Forward
| `Back
| `Both
| `None
]
| `Fontcolor of color
| `Fontname of string
| `Fontsize of int
| `Label of string
| `Labelfontcolor of color
| `Labelfontname of string
| `Labelfontsize of int
| `Penwidth of float
| `Style of [
| `Solid
| `Dashed
| `Dotted
| `Bold
| `Invis
]
]

Attributes of edges.

end

Interface with the dot engine

#
module DotAttributes : sig

DotAttributes extends CommonAttributes and implements ATTRIBUTES.

#
type graph = [
| `Bgcolor of color
| `BgcolorWithTransparency of color_with_transparency
| `Comment of string
| `Concentrate of bool
| `Fontpath of string
| `Layers of string list
| `Margin of float
| `Mclimit of float
| `Nodesep of float
| `Nslimit of int
| `Nslimit1 of int
| `Ranksep of float
| `Quantum of float
| `Rankdir of [
| `TopToBottom
| `LeftToRight
]
| `Ratio of [
| `Float of float
| `Fill
| `Compress
| `Auto
]
| `Samplepoints of int
| `Url of string
]

Attributes of graphs. They include all common graph attributes and several specific ones. All attributes described in the "dot User's Manual, February 4, 2002" are handled, excepted: clusterank, color, compound, labeljust, labelloc, ordering, rank, remincross, rotate, searchsize and style.

#
type vertex = [
| `Comment of string
| `Distortion of float
| `Fillcolor of color
| `FillcolorWithTransparency of color_with_transparency
| `Fixedsize of bool
| `Layer of string
| `Url of string
| `Z of float
]

Attributes of nodes. They include all common node attributes and several specific ones. All attributes described in the "dot User's Manual, February 4, 2002" are handled, excepted: bottomlabel, group, shapefile and toplabel.

#
type edge = [
| `Arrowhead of arrow_style
| `Arrowsize of float
| `Arrowtail of arrow_style
| `Comment of string
| `Constraint of bool
| `Headlabel of string
| `Headport of [
| `N
| `NE
| `E
| `SE
| `S
| `SW
| `W
| `NW
]
| `Headurl of string
| `Labelangle of float
| `Labeldistance of float
| `Labelfloat of bool
| `Layer of string
| `Minlen of int
| `Samehead of string
| `Sametail of string
| `Taillabel of string
| `Tailport of [
| `N
| `NE
| `E
| `SE
| `S
| `SW
| `W
| `NW
]
| `Tailurl of string
| `Weight of int
]

Attributes of edges. They include all common edge attributes and several specific ones. All attributes described in the "dot User's Manual, February 4, 2002" are handled, excepted: lhead and ltail.

#
type subgraph = {
# sg_name
: string;
# sg_attributes
: vertex list;
# sg_parent
: string option;
}

Subgraphs have a name and some vertices.

end
#
module type GraphWithDotAttrs = sig

Graph module with dot attributes

include Sig.G
#
val graph_attributes : t -> DotAttributes.graph list

Vertex attributes

#
val default_vertex_attributes : t -> DotAttributes.vertex list
#
val vertex_name : V.t -> string
#
val vertex_attributes : V.t -> DotAttributes.vertex list

Edge attributes

#
val default_edge_attributes : t -> DotAttributes.edge list
#
val edge_attributes : E.t -> DotAttributes.edge list
#
val get_subgraph : V.t -> DotAttributes.subgraph option

The box (if exists) which the vertex belongs to. Boxes with same names are not distinguished and so they should have the same attributes.

end
#
module Dot : functor (X : sig

Graph implementation. Sub-signature of Sig.G

#
type t
#
module V : sig
#
type t
end
#
module E : sig
#
type t
#
val src : t -> V.t
#
val dst : t -> V.t
end
#
val iter_vertex : (V.t -> unit) -> t -> unit
#
val iter_edges_e : (E.t -> unit) -> t -> unit

Graph, vertex and edge attributes.

#
val graph_attributes : t -> DotAttributes.graph list
#
val default_vertex_attributes : t -> DotAttributes.vertex list
#
val vertex_name : V.t -> string
#
val vertex_attributes : V.t -> DotAttributes.vertex list
#
val get_subgraph : V.t -> DotAttributes.subgraph option

The box (if exists) which the vertex belongs to. Boxes with same names are not distinguished and so they should have the same attributes.

#
val default_edge_attributes : t -> DotAttributes.edge list
#
val edge_attributes : E.t -> DotAttributes.edge list
end
) -> sig
#
val fprint_graph : Format.formatter -> X.t -> unit

fprint_graph ppf graph pretty prints the graph graph in the CGL language on the formatter ppf.

#
val output_graph : Pervasives.out_channel -> X.t -> unit

output_graph oc graph pretty prints the graph graph in the dot language on the channel oc.

end

The neato engine

#
module NeatoAttributes : sig
#
type graph = [
| `Margin of float * float
| `Start of int
| `Overlap of bool
| `Spline of bool
| `Sep of float
]

Attributes of graphs. They include all common graph attributes and several specific ones. All attributes described in the "Neato User's manual, April 10, 2002" are handled.

#
type vertex = [
| `Pos of float * float
]

Attributes of nodes. They include all common node attributes and several specific ones. All attributes described in the "Neato User's manual, April 10, 2002" are handled.

#
type edge = [
| `Id of string
| `Len of float
| `Weight of float
]

Attributes of edges. They include all common edge attributes and several specific ones. All attributes described in the "Neato User's manual, April 10, 2002" are handled.

#
type subgraph = {
# sg_name
: string;
# sg_attributes
: vertex list;
# sg_parent
: string option;
}

Subgraphs have a name and some vertices.

end
#
module Neato : functor (X : sig

Graph implementation. Sub-signature of Sig.G.

#
type t
#
module V : sig
#
type t
end
#
module E : sig
#
type t
#
val src : t -> V.t
#
val dst : t -> V.t
end
#
val iter_vertex : (V.t -> unit) -> t -> unit
#
val iter_edges_e : (E.t -> unit) -> t -> unit

Graph, vertex and edge attributes.

#
val graph_attributes : t -> NeatoAttributes.graph list
#
val default_vertex_attributes : t -> NeatoAttributes.vertex list
#
val vertex_name : V.t -> string
#
val vertex_attributes : V.t -> NeatoAttributes.vertex list
#
val get_subgraph : V.t -> NeatoAttributes.subgraph option

The box (if exists) which the vertex belongs to. Boxes with same names are not distinguished and so they should have the same attributes.

#
val default_edge_attributes : t -> NeatoAttributes.edge list
#
val edge_attributes : E.t -> NeatoAttributes.edge list
end
) -> sig
#
val set_command : string -> unit

Several functions provided by this module run the external program neato. By default, this command is supposed to be in the default path and is invoked by neato. The function set_command allows to set an alternative path at run time.

#
exception Error of string
#
val handle_error : ('a -> 'b) -> 'a -> 'b
#
val fprint_graph : Format.formatter -> X.t -> unit

fprint_graph ppf graph pretty prints the graph graph in the CGL language on the formatter ppf.

#
val output_graph : Pervasives.out_channel -> X.t -> unit

output_graph oc graph pretty prints the graph graph in the dot language on the channel oc.

end
end