This example is taken from compiler construction: Given an abstract syntax tree of an expression, a directed acyclic graph (dag) is to be constructed, which contains common subexpressions only once.
Given such a the dag created by this folding transformation, the original tree may be reconstructed by unfolding the dag.
The figure below (taken from ) depicts a concrete example for the expression (a/10 + (b-10))*(a/10 + (b-10)).
In the diagram below (taken from ), simple class diagrams are used to show one possible representation of this scenario.
A pair of a tree and a DAG is consistent, if traversing both the tree and the DAG in the same order (e.g., inorder) results in the same sequentialisation (the expression represented by the tree/DAG).
Properties [optional section]
Variants [optional section]
This is a particularly nasty example for TGGs and highlights a current limitation.
The problem is that the tree is best constructed top-down by unfolding the DAG, while the DAG is best constructed bottom-up by folding the tree.
As a TGG, however, describes the simultaneous construction of both structures, it is difficult (currently this seems actually impossible) to describe and unify these conflicting traversal strategies in a single (triple graph) grammar.
This might be a starting point to formally characterising the class of consistency relations that can be described with TGGs: perhaps the order of "information" in both structures must be the same or similar…
There are, however, some interesting advanced language features that exist for graph transformations and that might be integrated into TGGs and used to solve this problem in the future: (i) amalgamation, which could be used to achieve some form of unfolding/folding, and some form of path expressions to extract information far away in the tree/DAG.
References [optional section]
This example is taken from the following paper:
 Westfechtel, Bernhard. "Case-based exploration of bidirectional transformations in QVT Relations." Software & Systems Modeling (2016): 1-41.
Bernhard Westfechtel, Anthony Anjorin
Artefacts [optional section]
An implementation with QVT-R can be taken from: Westfechtel, Bernhard. "Case-based exploration of bidirectional transformations in QVT Relations." Software & Systems Modeling (2016): 1-41.