GrGen

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Debugging of a sequence generating a Koch-snowflake (the rules on the left, GrShell with highlighted current rule below, yComp with highlighted match in the host graph on the right)
Execution of the replace step

GrGen.NET (Graph Rewrite GENerator, .NET version) is a graph transformation tool which generates efficient C#-code (or CLI assemblies) out of declarative graph rewrite rule specifications.

Graphs and graph rewrite rules are specified by intuitive domain specific languages (semantics based on the SPO-approach, DPO available as well); they may get used from graph rewrite sequences, a simple, yet for most graph transformation tasks sufficient, special purpose programming language, or via an API by any CLI language.

GrGen is meant to be used for generating the algorithmic kernel of applications processing graph structured data (program graphs, social nets, chemical structures, ...).

For rapid prototyping and debugging, an interactive shell and a (VCG-)graph viewer are included in the package, which executes under Windows and Linux (Mono required) and is open source available under LGPL v3.

Specification sample[edit]

An example containing some graph model and rule specifications from the GrGen.NET-solution to the AntWorld-challenge posed at Grabats 08.

Graph model:

node class GridNode {
    food:int;
    pheromones:int;
}
node class GridCornerNode extends GridNode;
node class AntHill extends GridNode {
    foodCountdown:int = 10;
}
node class Ant {
    hasFood:boolean;
}

edge class GridEdge connect GridNode[1] -> GridNode[1];
edge class PathToHill extends GridEdge;
edge class AntPosition;

Rewrite Rules:

rule TakeFood(curAnt:Ant)
{
    curAnt -:AntPosition-> n:GridNode\AntHill;
    if { !curAnt.hasFood && n.food > 0; }
   
    modify {
        eval {
            curAnt.hasFood = true;
            n.food = n.food - 1;
        }
    }
}

rule SearchAlongPheromones(curAnt:Ant)
{
    curAnt -oldPos:AntPosition-> old:GridNode <-:PathToHill- new:GridNode;
    if { new.pheromones > 9; }
    
    modify {
        delete(oldPos);
        curAnt -:AntPosition-> new;
    }
}

test ReachedEndOfWorld(curAnt:Ant) : (GridNode)
{
    curAnt -:AntPosition-> n:GridNode\AntHill;
    negative { 
        n <-:PathToHill-;
    }
    return (n);
}

External links[edit]

Conference papers[edit]

See also[edit]