molfoundry.DG#

class molfoundry.DG(labelSettings=LabelSettings(LabelType.String, LabelRelation.Isomorphism), graphDatabase=[])[source]#

Bases: TSObject

Parameters:

graphDatabase (List[Graph])

property id: int#
property labelSettings: LabelSettings#
property graphDatabase: List[Graph]#
property createdGraphs: List[Graph]#
property locked: bool#
property hasActiveBuilder: bool#
property numVertices: int#
property vertices: List[Vertex]#
property numEdges: int#
property edges: List[HyperEdge]#
findVertex(g)[source]#
Parameters:

g (Graph)

Return type:

Vertex

findEdge(sources, targets)[source]#
Parameters:
Return type:

HyperEdge

build()[source]#
Return type:

Builder

print(printer=None, data=None)[source]#

Emit a static SVG visualization of the derivation graph.

Every DG vertex renders as an oval-framed molecule depiction (produced by the shared GraphSVGDrawer, in the mode / collapse-H setting picked up from printer) with the graph’s name captioned inside the oval. Every hyperedge with a single source and a single target collapses to a direct arrow labeled with e{id}; every multi-educt or multi-product hyperedge gets a small labeled square “junction” node with arrows from the educts into the junction and from the junction to the products.

Node positions come from a force-directed layout so junctions settle between their attached molecules; each oval’s dimensions match the aspect ratio of its molecule SVG’s viewBox so nothing gets stretched.

Everything is one inline SVG, so the dynamic light/dark theme follows the outer page’s [data-bs-theme] via CSS without needing any JavaScript.

Parameters:
class Vertex[source]#

Bases: TSObject

isNull()[source]#
Return type:

bool

property id: int#
property dg: DG#
property inDegree: int#
property inEdges: List[HyperEdge]#
property outDegree: int#
property outEdges: List[HyperEdge]#
property graph: Graph#
class HyperEdge[source]#

Bases: TSObject

isNull()[source]#
Return type:

bool

property id: int#
property dg: DG#
property numSources: int#
property sources: List[Vertex]#
property numTargets: int#
property targets: List[Vertex]#
property rules: List[Rule]#
property inverse: HyperEdge#
vertexMaps(limit=1, vertex_filter=None)[source]#
Parameters:
equals(other)[source]#
Parameters:

other (HyperEdge)

Return type:

Tuple[bool, bool]

print(printer=None)[source]#
Parameters:

printer (GraphPrinter | None)

class Builder(dg)[source]#

Bases: TSObject

Parameters:

dg (DG)

property dg: DG#
property isActive: bool#
execute(strategy, verbosity=2, ignoreRuleLabelTypes=False)[source]#
Parameters:
  • strategy (DGStrat) – The strategy to execute

  • verbosity (int) –

    The verbosity defaults to level 2. The levels have the following meaning:

    • 0 (or less): no information is printed.

    • 2: Repetition strategies print information for each round.

    • 4: All strategies print minimal information.

    • 6: Derivation predicate strategies and filtering strategies also print their predicates.

    • 8: Rule strategies print minimal information about graph binding.

    • 10: Rule strategies print more information about graph binding, including failure due to derivation predicates.

    • 50: Print information about morphism generation for rule composition.

    • 60: Print rule composition information.

  • ignoreRuleLabelTypes – Whether rules in the strategy should be checked beforehand for whether they have an associated LabelType which matches the one in the underlying derivation graph.

Return type:

ExecuteResult

apply(graphs, r, onlyProper=True, verbosity=0)[source]#
Parameters:
Return type:

List[HyperEdge]

addDerivation(d)[source]#
Parameters:

d (Derivations)

Return type:

HyperEdge

class ExecuteResult(state)[source]#

Bases: object

Parameters:

state (GraphState)

subset()[source]#
Return type:

List[Graph]

universe()[source]#
Return type:

List[Graph]