visualization.dot
dot
A minimal model of a Graphviz DOT graph, and its text.
Nothing here knows about music. layout builds a DotGraph from an OmkGraph, the tests inspect the model, and to_text writes the DOT that Graphviz reads.
Every id and attribute value is written double-quoted, with backslashes and quotes escaped and a newline as \n; except that a label written between < and > is passed through as it is, which is Graphviz’s own convention for an HTML-like label.
>>> graph = DotGraph(attrs={"rankdir": "LR"})
>>> graph.nodes.append(DotNode("a", {"label": "say \"hi\""}))
>>> graph.nodes.append(DotNode("b", {"label": "<b<SUP>2</SUP>>"}))
>>> graph.edges.append(DotEdge("a", "b", {"constraint": "false"}))
>>> graph.ranks.append(["a", "b"])
>>> print(graph.to_text())
digraph {
rankdir="LR";
"a" [label="say \"hi\""];
"b" [label=<b<SUP>2</SUP>>];
{ rank=same; "a" -> "b" [style="invis"]; }
"a" -> "b" [constraint="false"];
}
<BLANKLINE>Attributes
| Name | Description |
|---|---|
| HTML_LABEL_KEYS |
Classes
| Name | Description |
|---|---|
| DotNode | A node statement: its id and attributes. |
| DotEdge | An edge statement, optionally through a port at either end. |
| DotGraph | A directed graph: graph, node and edge defaults, the nodes, the edges, |
Functions
| Name | Description |
|---|---|
| is_html_label | Whether value is an HTML-like label: written between < and >. |
| quote | A double-quoted DOT string. |
| attribute_list | [key="value", ...] in insertion order, or nothing for no attributes. |