Class: Grammar

Grammar(json, optsopt)

new Grammar(json, optsopt)

Represents a graph grammar.

Parameters:
Name Type Attributes Description
json Object

A description of the graph grammar, matching the JSON schema.

opts Object <optional>

Options

Properties
Name Type Attributes Description
canonical Boolean <optional>

If true, the grammar JSON must be strictly canonical: both LHS and RHS must have full node and edge sections

no_llm Boolean <optional>

If true, the command-line LLM plugin will not be registered

llm Boolean <optional>

Command-line interface to the LLM plugin. The default is llm

Source:

Methods

canonicalJson() → {Object}

Returns the canonical JSON for a graph grammar.

Source:
Returns:

The JSON representation of the grammar.

Type
Object

evolve(optsopt) → {EvolveReturnValue}

Evolve a graph using a graph grammar.

Parameters:
Name Type Attributes Description
opts Object <optional>

Options influencing the way the grammar is applied.

Properties
Name Type Attributes Description
rnd Object <optional>

Random number generator. Default is MersenneTwister

seed Integer <optional>

Seed for random number generator.

graph Graph <optional>

Initial graphlib graph. Default is a graph containing a single node whose ID is given by opts.start

start String <optional>

Default label for the starting node of the initial graph. Default is to use the start property of the grammar.

limit Integer <optional>

Maximum number of transformation rules to apply. Default is to use the limits specified by the grammar or subgrammars, if any

stage Integer <optional>

Apply a specific stage of the grammar. GraphGram's grammars can consist of multiple subgrammars. Default is to apply all of them, one after the other.

verbose Integer <optional>

Verbosity level. 0 is quiet (the default), 1 is the default for the CLI, 2+ is loud.

Source:
Returns:

An object containing the results of the grammar application.

Type
EvolveReturnValue

makeSchema() → {Object}

Get the JSON schema for a graph grammar.

Source:
Returns:

The JSON schema.

Type
Object

toDot(graph) → {string}

Generate a GraphViz dot-format description of a graph.

Parameters:
Name Type Description
graph Object

A graphlib graph.

Source:
Returns:

The graph in GraphViz dot format.

Type
string