| rule Tree2Node | |
| transform t : Tree!Tree | |
| to n : Graph!Node { | |
| n.name = t.label; | |
| if (t.parent.isDefined()) { | |
| var e : new Graph!Edge; | |
| e.source ::= t.parent; | |
| e.target = n; | |
| } | |
| else { | |
| // root node: create root element for the graph model | |
| new Graph!Graph; | |
| } | |
| // add node to graph | |
| Graph!Graph.allInstances.first().nodes.add(n); | |
| } |