Jump to content

GrGen

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 129.13.72.153 (talk) at 14:37, 2 September 2008 (Small fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

GrGen.NET (Graph Rewrite GENerator, .NET version) is a graph transformation tool which generates efficient C#-code (or .NET-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 .NET 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 GPL v3.

Specification sample

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

Conference papers

See also