Specification of a graphgram stochastic grammar for graph transformation.

Type: object

A top-level grammar, consisting of just one stage.

No Additional Properties

Type: array of object

The list of subgraph transformation rules in this grammar.

No Additional Items

Each item of this array must be:

Type: object

An individual subgraph transformation rule. Each rule proceeds by matching a subgraph whose pattern is specified on the left-hand side (the lhs), and replacing it with a subgraph specified on the right-hand side (rhs). There are various different syntactical forms depending on the complexity and topology of the matching and replacement subgraphs, and whether properties (like edges and labels) are to be changed or copied over unmodified.

No Additional Properties

Type: string

The name of this rule.


This block specifies a pattern with which to match the subgraph on the left-hand side of the transformation rule.

Type: array of string

An array of node labels. The matched subgraph is a chain of nodes.

No Additional Items

Each item of this array must be:

Type: string

A node label.

Type: string

A single node label. The matched subgraph contains exactly one node.The string can be a regular expression, to be matched against the node label.

Type: object

A full description, including nodes and edges, of the subgraph to be matched.

No Additional Properties

Type: array

The set of nodes in the matching subgraph.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:


Type: string

A node label.This pattern will match any node that has the corresponding string label.

Type: array of string

A (node ID, node label) pair; both are strings. The ID can be used to reference the node elsewhere in the rule.

Must contain a minimum of 2 items

Must contain a maximum of 2 items

No Additional Items

Each item of this array must be:

Type: object

A pattern for matching a node in a subgraph.

No Additional Properties

Type: string

A node identifier that can be used to reference the node elsewhere in the rule.

Must match regular expression: ^[a-zA-Z_0-9]+$

Type: object

A query expression for matching a label on the left-hand side of a subgraph transformation rule.

Type: string, number, boolean or array

This query will match any label that has exactly the specified type and value.

Type: object

A compound query expression that is formed by combining, or modifying, one or more constituent query expressions.

No Additional Properties

Type: object

The label object must exactly match the given query expression, with no additional properties.

Same definition as label

Type: object

The label object must match the given query expression, but is allowed to contain additional properties.

Same definition as label

Type: object

A recursive descent search of the label object must find an element that matches the given query expression.

Same definition as label

Type: object

The label must NOT match the given query expression.

Same definition as label

Type: array

The label must match all of the query expressions given in the list.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:

Type: object

A query for matching a label in a graph entity (i.e. a node or edge).

Same definition as label

Type: array

The label must match one of the query expressions given in the list.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:

Type: object

A query for matching a label in a graph entity (i.e. a node or edge).

Same definition as label

Type: string

A flexible user-defined query. The text value of this query expression, when eval'd, defines a JavaScript function which, when called with the label as its sole argument, must return a truthy value.

Type: object

The label must be a JSON object, it must have a key that matches the given key (which can be any string that does not begin with a "$" character), and the value must match the query expression associated with that key.

No Additional Properties

All properties whose name matches the following regular expression must respect the following conditions

Property name regular expression: ^[^$].*$
Type: object

A query for matching a label in a graph entity (i.e. a node or edge).

Same definition as label

Type: boolean

If true, then any graph node that matches this pattern rule cannot have any neighbors that are not also in the subgraph defined by the pattern rule

Type: array

The set of edges in the matching subgraph. Note that, unless the induce property is set (within this rule or at a higher level in the grammar), this match is permissive rather than strict: the subgraph is allowed to contain more edges than specified here. In contrast, if induce is set, then ONLY the edges in this subgraph are allowed for a match.

No Additional Items

Each item of this array must be:


An edge being matched on the left-hand side of a transformation rule. Note that the edge may be specified as an array of the form [v,w,label,id] or as an object with those properties; the two are functionally equivalent. v and w represent source and target node IDs, respectively; label is a query expression to match edge labels; and id is a temporary identifier for the edge. label and id are optional.

Type: array

A tuple describing an edge being matched on the left-hand side of a transformation rule.

Must contain a minimum of 2 items

Must contain a maximum of 4 items

No Additional Items

Tuple Validation

Item at 1 must be:
Type: string or number

The source node of the edge, using the node numbering or naming scheme defined in the node block.

Item at 2 must be:
Type: string or number

The target node of the edge, using the node numbering or naming scheme defined in the node block.

Item at 3 must be:
Type: object

A query expression for matching the edge label.

Same definition as label
Item at 4 must be:
Type: string

A temporary identifier for the edge being matched. This is temporary in the sense that it is defined only while the transformation rule is being applied.

Type: object

An object describing an edge being matched on the left-hand side of a transformation rule.

No Additional Properties

Type: string

The source node of the edge, using the node naming scheme defined in the node block.

Same definition as id

Type: string

The target node of the edge, using the node naming scheme defined in the node block.

Same definition as id

Type: object

A query expression for matching the edge label.

Same definition as label

Type: string

A temporary identifier for the edge being matched. This is temporary in the sense that it is defined only while the transformation rule is being applied.

Same definition as id


This block specifies the subgraph generated on the right-hand side of the transformation rule, replacing the matched subgraph on the left-hand side.

Type: array of string

An array of node labels. The replacement subgraph is a chain of nodes. The head and tail properties will be automatically set to (respectively) the first and last nodes on the left-hand side of the rule.

No Additional Items

Each item of this array must be:

Type: string

A node label.

Type: string

A single node label. The replacement subgraph contains exactly one node. The head and tail properties will automatically be set to (respectively) the first and last nodes on the left-hand side of the rule.

Type: object

A full description, including nodes and edges, of the subgraph to be used for replacement. If the node block is absent, it will be copied from the left-hand side.

No Additional Properties

Type: array

The set of nodes in the replacement subgraph.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:


Type: array of string

A (node ID, node label) pair; both are strings. The ID either refers to a node that was matched on the left-hand side of the rule, or is completely new.

Must contain a minimum of 2 items

Must contain a maximum of 2 items

No Additional Items

Each item of this array must be:

Type: object

An incremental update to a node in the matched subgraph.

No Additional Properties

Type: string

A node identifier that refers to a node that was matched on the left-hand side of the rule.

Same definition as id

Type: object

An update to the existing node label, whose properties will be copied over to the existing node label using Lodash assign semantics. It follows that this update will typically be an object rather than another type of value (though the schema also allows string-valued, array-valued, or numeric values here).

Type: string, number, boolean or array

Generates a label with exactly the specified type and value. For string-valued labels, or arrays that include strings, the string may include substrings of the form ${id.label} where id is an identifier that has been assigned, during this transformation rule, to a previously referenced node or edge.

Type: object

Generates a label using a functional expression that typically involves evaluating a string as JavaScript. The JavaScript may refer to the labels of nodes or edges that have previously been assigned IDs, using the syntax $id.label.

No Additional Properties

Type: string, array or object

Generates a label by evaluating a JavaScript string.

Type: array

Generates a label by applying extend to its arguments, where the semantics of extend skip undefined values.

Must contain a minimum of 2 items

No Additional Items

Each item of this array must be:

Type: array

Generates a label by applying the Lodash assign function to its arguments, where the semantics of assign do not skip undefined values.

Must contain a minimum of 2 items

No Additional Items

Each item of this array must be:

Type: array

Generates a label by applying the Lodash merge function to its arguments, i.e. performing a recursive traversal and attempting to merge at each level.

Must contain a minimum of 2 items

No Additional Items

Each item of this array must be:


Generate text using command-line LLM interface. This option is only enabled in the command-line tool. The default LLM toolname is llm, which must be separately installed: https://github.com/simonw/llm

Type: object

Generates a JSON object with the given key(s) (which can be any string that does not begin with a "$" character), mapping to value(s) which are themselves label expressions.

No Additional Properties

All properties whose name matches the following regular expression must respect the following conditions

Property name regular expression: ^[^$].*$
Type: object
Same definition as update
Type: object

A description of a node in the replacement subgraph.

No Additional Properties

Type: string

A node identifier that either refers to a node that was matched on the left-hand side of the rule, or is completely new.

Same definition as id

Type: object

A recipe for generating a label on the right-hand side of a subgraph transformation rule.

Same definition as update

Type: array

The set of edges in the replacement subgraph. (Note that under some circumstances, edges will be automatically added even if not specified here. Specifically, if the node property is array-valued, then a chain of edges will be added automatically between consecutive nodes in the list.)

No Additional Items

Each item of this array must be:


An edge being added on the right-hand side of a transformation rule. The edge may be specified in a variety of ways, but the basic idea is to either specify a source and target (v,w) or an identifier referencing an existing edge (id), and then to replace the label completely (label) or update it incrementally (update). Specifically the edge can be a [v,w,label] tuple (where v and w are the source and target of the new edge), as an {id,label} object (where id is the ID of an edge introduced on the left-hand side of the transformation rule; in this and the [v,w,label] tuple the label is optional, and will be copied from an existing edge if one exists), as an {id,update} object (where update represents an incremental update to the existing edge label), as a {v,w,update} object, as a string (which will be interpreted as the ID of an existing edge), or as a {v,w,label} object.

Type: array

A tuple describing an edge being added on the right-hand side of a transformation rule.

Must contain a minimum of 2 items

Must contain a maximum of 3 items

No Additional Items

Tuple Validation

Item at 1 must be:
Type: string or number

The source node of the edge, using the node numbering or naming scheme defined in the node block.

Item at 2 must be:
Type: string or number

The target node of the edge, using the node numbering or naming scheme defined in the node block.

Item at 3 must be:
Type: object

An expression for the replacement edge label.

Same definition as update
Type: object

An object describing an edge being added on the right-hand side of a transformation rule.

No Additional Properties

Type: string

An edge identifer from the subgraph matched on the left-hand side of the transformation rule.

Same definition as id

Type: object

A recipe for generating a label on the right-hand side of a subgraph transformation rule.

Same definition as update
Type: object

An object describing an incremental update to an edge on the right-hand side of a transformation rule.

No Additional Properties

Type: object

A incremental update to the existing edge label.

Same definition as update
Type: object

An object describing an incremental update to an edge on the right-hand side of a transformation rule.

No Additional Properties

Type: string

The source node of the edge, using the node identifiers defined in the node block.

Same definition as id

Type: string

The target node of the edge, using the node identifiers defined in the node block.

Same definition as id

Type: object

A incremental update to the existing edge label.

Same definition as update
Type: string

An edge identifer from the subgraph matched on the left-hand side of the transformation rule. The edge will be copied unmodified.

Type: object

An object describing an edge being added on the right-hand side of a transformation rule.

No Additional Properties

Type: string

The source node of the edge, using the node naming scheme defined in the node block.

Same definition as id

Type: string

The target node of the edge, using the node naming scheme defined in the node block.

Same definition as id

Type: boolean

If true, then the subgraph induced by the nodes on the left-hand side of the rule must exactly match the subgraph as specified in the rule: no additional nodes within the subgraph are allowed.

Type: string

A string that will be passed to JavaScript's eval for evaluation, to test whether the match should proceed. Use $id.label for labels, $id.match[n] for n'th matching group, $$iter for iteration#, $$graph for graph.

Type: string or number

A probabilistic weight that is used to determine which rules should be randomly applied, in the event that multiple patterns match.

Type: number

The maximum number of times this rule can be used to transform the graph.

Type: string

If a type is specified, then any limit specified for this rule is interpreted as the maximum number of times any rule with the same type can be used.

Type: number

The minimum number of times another transformation rule must be applied to the graph before this rule can be used.

Type: string

The name of this grammar.

Type: number

The maximum number of rule applications.

Type: boolean

Default value of the induced parameter, which governs the specificty of subgraph-matching. Can be overridden by the induced parameter for stages and rules.

Type: object

The start node label for the default initial graph.

Type: object

A top-level grammar, consisting of one or more stages.

No Additional Properties

Type: array

The successive stages to be applied. Each stage is a separate subgrammar of transformations.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:

Type: object

A subgrammar, corresponding to an individual stage of graph transformation.

No Additional Properties

Type: array of object

The list of subgraph transformation rules in this grammar.

Same definition as rules

Type: string

The name of this subgrammar.

Type: number

The maximum number of rule applications.

Type: boolean

Default value of the induced parameter, which governs the specificty of subgraph-matching. Can be overridden by the induced parameter for stages and rules.

Type: string

The name of this grammar.

Type: number

The maximum number of rule applications.

Type: boolean

Default value of the induced parameter, which governs the specificty of subgraph-matching. Can be overridden by the induced parameter for stages and rules.

Type: object

The start node label for the default initial graph.