Module Bigraph.Dot

Dot (graphviz) emission for the BigraphER SVG pipeline.

A rendered bigraph is written as dot source and piped to dot -Tsvg untouched; there is no post-processing. This module owns the dot assembly primitives and the bigraph vocabulary (element keys, CSS classes, exact statement formats) that the bigraph renderers share. The consumers (Nodes.to_dot, Place.to_dot, Link.to_dot, Big.to_dot) keep their layout logic and build the diagram out of these statements.

Customising the SVG

The digraph references a stylesheet (by default style.css for bigraphs, style_ts.css for transition systems) written next to the exported SVG only when a file of the same name is absent. Edit that file to customise the rendering without touching the dot source or rebuilding anything.

Every element carries the CSS classes listed in V; graphviz emits the look as presentation attributes on the child elements (path / ellipse / text / polygon) and CSS overrides them, so target the children, not the g.node / g.edge groups:

  .control-A ellipse { fill: lightyellow; }
  .edge.link path { stroke: blue; }

Elements carry stable ids (v0, r0, e0 for nodes; s0, iA, etc.) addressable directly in CSS:

  #e0 polygon { fill: gold; }

Hover effects use standard CSS :hover:

  .hub:hover polygon { fill: #22c55e; }

The full default stylesheets live in Style.bigraph and Style.transition; their header comments list every class and id in use.

val sanitise : string -> string

Collapse runs of characters outside A-Za-z0-9_- to a single '-', for use as a CSS class token.

Generic statement builders, shared with the transition-system renderer.

val header : ?ranksep:string -> ?nodesep:string -> ?stylesheet:string -> string -> string

header name is the digraph opening: the digraph line plus the graph attributes (newrank = true, ranksep, nodesep, stylesheet). The spacing values are preformatted strings; defaults ranksep = "0.3", nodesep = "0.30", stylesheet = "style.css".

The closing brace.

val node : key:string -> attrs:string -> string

node ~key ~attrs is key [ attrs ];\n — a node statement with the attribute list in the given order.

val edge : src:string -> dst:string -> attrs:string -> string

edge ~src ~dst ~attrs is src -> dst [ attrs ];\n — an edge statement with the attribute list in the given order.

val invis_edge : src:string -> dst:string -> string

invis_edge ~src ~dst is an unstyled layout edge: src -> dst [ style=invis ];\n.

val rank : [ `Same | `Source | `Sink ] -> string list -> string

rank r row is a rank=same|source|sink block seating the given nodes, or ""' for an empty row. All three arms end in a semicolon before the closing brace.

val rank_same_nodes : string list -> string

rank_same_nodes row is a rank=same block for the same-depth node groups in Bigraph.Place: like `rank [`Same] row but with the semicolon after the closing brace, matching the original place format byte for byte.

module V : sig ... end

The bigraph element vocabulary.

Transition-system (TS / MDP) statements, shared by the TS renderers (Ts.to_dot and the BRS f_edges wrappers).

module Ts : sig ... end