Draws each group of partition as a cluster, with a label by group ID.
Nodes in no group stay outside every cluster, and a group without a node to write has no
cluster. A label of null or undefined leaves a cluster unlabeled, also when the graph has a
label, which Graphviz would otherwise repeat on every cluster.
Time: O(1).
the groups, over the nodes of the graph, such as an Sccs
called with a group ID, returns the label of its cluster, or null or undefined
this writer
Sets the hook that adds DOT attributes, such as color or style, to each edge, by edge
index.
The hook receives the label from DotWriter.edgeLabel as the attribute label, which it
can replace or remove.
Time: O(1).
called with each edge that is written, puts its attributes
this writer
Sets the label of each edge, by edge index; null or undefined leaves an edge unlabeled.
Time: O(1).
called with an edge index, returns the label of the edge, or null or undefined
this writer
Sets the hook that adds DOT attributes, such as shape, color or style, to each node, by
node ID.
The hook receives the label from DotWriter.nodeLabel as the attribute label, which it
can replace or remove.
Time: O(1).
called with each node that is written, puts its attributes
this writer
Restricts the text to the nodes that include accepts and the edges between them.
Node IDs stay those of the graph, so the hooks keep reading the same arrays.
Time: O(1).
called with a node ID, returns whether to write the node
this writer
Sets the label of each node, by node ID; null or undefined leaves a node unlabeled, and
Graphviz then shows its node ID.
Time: O(1).
called with a node ID, returns the label of the node, or null or undefined
this writer
Switches to the undirected reading of the graph: a graph with -- edges instead of a
digraph.
The edges a -> b and b -> a become one, written as the edge from the lower node ID; the
edge hooks receive its edge index.
Time: O(1).
this writer
Writes the graph to out, as DOT text. out is anything with a method write(text), such as
process.stdout or a file stream of Node.js (Java: an Appendable).
The text goes to out.write in chunks of about 8 KiB characters, not piece by piece.
Time: O(nodeCount + edgeCount + groupCount), plus the hooks, with groupCount the number of groups of the partition drawn as clusters; in the undirected reading, O(log outDegree(target)) more per edge. Memory: nodeCount bytes while it runs, and a chunk of text.
where the text goes; not closed
Error what out.write throws (Java: IOException), or if an attribute hook puts a
name that is not an identifier or is a DOT keyword; the text written before the error has
gone to out. Only a write that throws fails the call. A stream reports its errors
through its own event or promise, which the caller must watch (see TextSink)
Returns the DOT text of the graph, as DotWriter.write writes it.
Time: as for DotWriter.write. Memory: the text for the result; while it runs, up to twice as much again and nodeCount bytes more.
the DOT text
Error as for DotWriter.write
Staticof
A writer of DOT (the language of Graphviz) that labels and styles a graph with the caller's data by node ID and edge index.
DotWriter.of returns a writer for a graph, the methods that configure it return the writer again, and DotWriter.write or DotWriter.writeToString write the text. The graph holds no data, so labels and attributes come from hooks that receive a node ID or an edge index and read the caller's arrays. Here, the packages of a small program get their names from
names. The strongly connected componentssccstell which packages are in a cycle, and these are drawn in red:Nodes are named by their node IDs. The text lists the graph attributes, the clusters in group order with their nodes, then the nodes in no cluster, then the edges in edge index order, so the same graph and hooks always give the same text. A node outside the clusters is listed only if it has a label or attributes, or no edge in the text; Graphviz creates the other nodes from their edges.
Labels and attribute values are written as quoted strings: the writer escapes quotes and backslashes and turns line breaks into DOT's
\n. Graphviz decodes HTML entities such as<in the attributeslabel,xlabel,headlabelandtaillabel. In these, the writer also turns&into&, so that a label shows exactly its text. Other values, such as aURL, keep their&. NUL, which DOT cannot hold, is written as U+FFFD.Attribute names must be identifiers - an ASCII letter or underscore, then ASCII letters, digits or underscores - other than the DOT keywords
node,edge,graph,digraph,subgraphandstrict, in any letter case.A writer keeps its configuration and can write any number of times. For Markdown and documentation,
MermaidWriterin the package@kobayami/graphity-mermaidwrites a Mermaid flowchart.Instances are mutable.