Code Monkey home page Code Monkey logo

graph-rule-generation's Introduction

Maven Central Lines of Code Coverage Code Smells Bugs

Graph-rule-generation

The library is available on Maven Central and new versions can be found faster on the SonaType repository.

Usage

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.

Generating graphs

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:

Generated Groove Graph

Generating graph transformation rules

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:

Generated Groove GT-Rule

The rule can be applied to our graph generated above. The result is the following:

Result rule

Generating graph transformation systems

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);

Motivation

The tool is used in my PhD research see code or my website.

graph-rule-generation's People

Contributors

timkraeuter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.