Appearance
Class: Graphviz
graphviz.Graphviz
The Graphviz layout algorithms take descriptions of graphs in a simple text language, and make diagrams in useful formats, such as images and SVG for web pages or display in an interactive graph browser.
Graphviz has many useful features for concrete diagrams, such as options for colors, fonts, tabular node layouts, line styles, hyperlinks, and custom shapes.
See graphviz.org for more details.
ts
import { Graphviz } from "@hpcc-js/wasm/graphviz";
const graphviz = await Graphviz.load();
const dot = "digraph G { Hello -> World }";
const svg = graphviz.dot(dot);
Online Demos
- https://raw.githack.com/hpcc-systems/hpcc-js-wasm/trunk/index.html
- https://observablehq.com/@gordonsmith/graphviz
Methods
load
▸ load(): Promise
<Graphviz
>
Compiles and instantiates the raw wasm.
INFO
In general WebAssembly compilation is disallowed on the main thread if the buffer size is larger than 4KB, hence forcing load
to be asynchronous;
Returns
Promise
<Graphviz
>
A promise to an instance of the Graphviz class.
Defined in
unload
▸ unload(): void
Unloades the compiled wasm instance.
Returns
void
Defined in
version
▸ version(): string
Returns
string
The Graphviz c++ version
Defined in
layout
▸ layout(dotSource
, outputFormat?
, layoutEngine?
, options?
): string
Performs layout for the supplied dotSource, see The DOT Language for specification.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
layoutEngine | Engine | "dot" | The type of layout to perform. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
acyclic
▸ acyclic(dotSource
, doWrite?
, verbose?
): Object
acyclic is a filter that takes a directed graph as input and outputs a copy of the graph with sufficient edges reversed to make the graph acyclic. The reversed edge inherits all of the attributes of the original edge. The optional file argument specifies where the input graph is stored; by default.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
doWrite | boolean | false | Enable output is produced, though the return value will indicate whether the graph is acyclic or not. |
verbose | boolean | false | Print information about whether the file is acyclic, has a cycle or is undirected. |
Returns
Object
{ acyclic: boolean, num_rev: number, outFile: string }
acyclic
will be true if a cycle was found, num_rev
will contain the number of reversed edges and outFile
will (optionally) contain the output.
Name | Type |
---|---|
acyclic | boolean |
num_rev | number |
outFile | string |
Defined in
tred
▸ tred(dotSource
, verbose?
, printRemovedEdges?
): Object
tred computes the transitive reduction of directed graphs, and prints the resulting graphs to standard output. This removes edges implied by transitivity. Nodes and subgraphs are not otherwise affected. The ‘‘meaning’’ and validity of the reduced graphs is application dependent. tred is particularly useful as a preprocessor to dot to reduce clutter in dense layouts. Undirected graphs are silently ignored.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
verbose | boolean | false | Print additional information. |
printRemovedEdges | boolean | false | Print information about removed edges. |
Returns
Object
{ out: string, err: string }
.
Name | Type |
---|---|
out | string |
err | string |
Defined in
unflatten
▸ unflatten(dotSource
, maxMinlen?
, do_fans?
, chainLimit?
): string
unflatten is a preprocessor to dot that is used to improve the aspect ratio of graphs having many leaves or disconnected nodes. The usual layout for such a graph is generally very wide or tall. unflatten inserts invisible edges or adjusts the minlen on edges to improve layout compaction.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
maxMinlen | number | 0 | The minimum length of leaf edges is staggered between 1 and len (a small integer). |
do_fans | boolean | false | Enables the staggering of the -maxMinlen option to fanout nodes whose indegree and outdegree are both 1. This helps with structures such as a -> {w x y } -> b. This option only works if the -maxMinlen flag is set. |
chainLimit | number | 0 | Form disconnected nodes into chains of up to len nodes. |
Returns
string
A string containing the "unflattened" dotSource.
Defined in
circo
▸ circo(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the circo layout, is equivalent to layout(dotSource, outputFormat, "circo");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
dot
▸ dot(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the dot layout, is equivalent to layout(dotSource, outputFormat, "dot");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
fdp
▸ fdp(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the fdp layout, is equivalent to layout(dotSource, outputFormat, "fdp");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
sfdp
▸ sfdp(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the sfdp layout, is equivalent to layout(dotSource, outputFormat, "sfdp");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
neato
▸ neato(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the neato layout, is equivalent to layout(dotSource, outputFormat, "neato");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
osage
▸ osage(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the osage layout, is equivalent to layout(dotSource, outputFormat, "osage");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
patchwork
▸ patchwork(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the patchwork layout, is equivalent to layout(dotSource, outputFormat, "patchwork");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
twopi
▸ twopi(dotSource
, outputFormat?
, options?
): string
Convenience function that performs the twopi layout, is equivalent to layout(dotSource, outputFormat, "twopi");
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dotSource | string | undefined | Required - graph definition in DOT language |
outputFormat | Format | "svg" | The format of the result. |
options? | Options | undefined | Advanced Options for images, files, yInvert and nop. |
Returns
string
A string containing the calculated layout in the format specified by outputFormat
Defined in
nop
▸ nop(dotSource
): string
Convenience function that performs the nop layout, is equivalent to layout(dotSource, "dot", "nop");
.
Parameters
Name | Type | Description |
---|---|---|
dotSource | string | Required - graph definition in DOT language |
Returns
string
A string containing the "pretty printed" dotSource.
Defined in
nop2
▸ nop2(dotSource
): string
Convenience function that performs the nop2 layout, is equivalent to layout(dotSource, "dot", "nop2");
.
Parameters
Name | Type | Description |
---|---|---|
dotSource | string | Required - graph definition in DOT language |
Returns
string
A string containing the "pretty printed" dotSource.