blob: 645782da5c5357122db1f8b2b0938fb3e87657f9 [file] [log] [blame]
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);
}