The library is available on Maven Central and new versions can be found faster on the SonaType repository.
This library allows users to programmatically generate graphs, graph transformation rules, and even entire graph transformation systems. Currently, it targets the graph transformation tool Groove.
Graphs are created using the GrooveGraphBuilder and can be written for Groove via the GrooveRuleAndGraphWriter. Here is an example of how to use the builder:
GrooveGraphBuilder builder = new GrooveGraphBuilder();
GrooveNode a = new GrooveNode("A");
GrooveNode b = new GrooveNode("B");
GrooveNode c = new GrooveNode("C");
GrooveNode d = new GrooveNode("D");
GrooveGraph graph = builder.name("Graph")
.addEdge("AB",a,b) // Nodes are automatically added.
.addEdge("CD",c,d)
.build();
This results in the following Groove graph:
Graphs are created using the GrooveRuleBuilder and can be written for Groove via the GrooveRuleAndGraphWriter. Here is an example of how to use the builder:
GrooveRuleBuilder ruleBuilder = new GrooveRuleBuilder();
ruleBuilder.startRule("sampleRule");
// Context nodes and edges
GrooveNode a = ruleBuilder.contextNode("A");
GrooveNode b = ruleBuilder.contextNode("B");
ruleBuilder.contextEdge("AB",a,b);
// Deleting nodes and edges
GrooveNode c = ruleBuilder.deleteNode("C");
GrooveNode d = ruleBuilder.deleteNode("D");
ruleBuilder.deleteEdge("CD",c,d);
// Adding nodes and edges
GrooveNode e = ruleBuilder.addNode("E");
GrooveNode f = ruleBuilder.addNode("F");
ruleBuilder.addEdge("EF",e,f);
// NAC nodes and edges
GrooveNode g = ruleBuilder.nacNode("G");
GrooveNode h = ruleBuilder.nacNode("H");
ruleBuilder.nacEdge("GH",g,h);
GrooveGraphRule gtRule = ruleBuilder.buildRule();
This results in the following Groove graph transformation rule:
The rule can be applied to our graph generated above. The result is the following:
GrooveGTSBuilder gtsBuilder = new GrooveGTSBuilder().name("README").layout(true);
GrooveGraphBuilder startGraphBuilder = gtsBuilder.startGraph();
// Build start graph as shown above ...
GrooveRuleBuilder ruleBuilder = gtsBuilder.rules();
// Build rules as shown above ...
// Add groove properties if needed
gtsBuilder.addProperty("matchInjective", "true");
// Write each part of the GTS individually.
gtsBuilder.writeStartGraph(targetDir);
gtsBuilder.writeRules(targetDir);
gtsBuilder.writePropertiesFile(targetDir);
// Write the whole GTS, i.e., start graph, rules, and properties file into a new dir.
gtsBuilder.writeGTS(targetDir);