Skip to content

@hpcc-js/wasm-root


Class: Graphviz

Defined in: graphviz/src/graphviz.ts:93

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

Methods

load()

static load(): Promise<Graphviz>

Defined in: graphviz/src/graphviz.ts:107

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.


unload()

static unload(): void

Defined in: graphviz/src/graphviz.ts:116

Unloades the compiled wasm instance.

Returns

void


version()

version(): string

Defined in: graphviz/src/graphviz.ts:123

Returns

string

The Graphviz c++ version


layout()

layout(dotSource, outputFormat, layoutEngine, options?): string

Defined in: graphviz/src/graphviz.ts:136

Performs layout for the supplied dotSource, see The DOT Language for specification.

Parameters

dotSource

string

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

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


acyclic()

acyclic(dotSource, doWrite, verbose): object

Defined in: graphviz/src/graphviz.ts:167

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

dotSource

string

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.

acyclic

acyclic: boolean

num_rev

num_rev: number

outFile

outFile: string


tred()

tred(dotSource, verbose, printRemovedEdges): object

Defined in: graphviz/src/graphviz.ts:201

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

dotSource

string

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 }.

out

out: string

err

err: string


unflatten()

unflatten(dotSource, maxMinlen, do_fans, chainLimit): string

Defined in: graphviz/src/graphviz.ts:235

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

dotSource

string

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.


circo()

circo(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:265

Convenience function that performs the circo layout, is equivalent to layout(dotSource, outputFormat, "circo");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


dot()

dot(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:277

Convenience function that performs the dot layout, is equivalent to layout(dotSource, outputFormat, "dot");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


fdp()

fdp(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:289

Convenience function that performs the fdp layout, is equivalent to layout(dotSource, outputFormat, "fdp");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


sfdp()

sfdp(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:301

Convenience function that performs the sfdp layout, is equivalent to layout(dotSource, outputFormat, "sfdp");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


neato()

neato(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:313

Convenience function that performs the neato layout, is equivalent to layout(dotSource, outputFormat, "neato");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


osage()

osage(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:325

Convenience function that performs the osage layout, is equivalent to layout(dotSource, outputFormat, "osage");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


patchwork()

patchwork(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:337

Convenience function that performs the patchwork layout, is equivalent to layout(dotSource, outputFormat, "patchwork");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


twopi()

twopi(dotSource, outputFormat, options?): string

Defined in: graphviz/src/graphviz.ts:349

Convenience function that performs the twopi layout, is equivalent to layout(dotSource, outputFormat, "twopi");.

Parameters

dotSource

string

Required - graph definition in DOT language

outputFormat

Format = "svg"

The format of the result.

options?

Options

Advanced Options for images, files, yInvert and nop.

Returns

string

A string containing the calculated layout in the format specified by outputFormat


nop()

nop(dotSource): string

Defined in: graphviz/src/graphviz.ts:359

Convenience function that performs the nop layout, is equivalent to layout(dotSource, "dot", "nop");.

Parameters

dotSource

string

Required - graph definition in DOT language

Returns

string

A string containing the "pretty printed" dotSource.


nop2()

nop2(dotSource): string

Defined in: graphviz/src/graphviz.ts:369

Convenience function that performs the nop2 layout, is equivalent to layout(dotSource, "dot", "nop2");.

Parameters

dotSource

string

Required - graph definition in DOT language

Returns

string

A string containing the "pretty printed" dotSource.

Released under the Apache-2.0 License.