Graph rewriting
Graph transformation, or Graph rewriting, concerns the technique of creating a new graph out of an original graph using some automatic machine. It has numerous applications, ranging from software verification to layout algorithms.
Graph transformations can be used as a computation abstraction. The basic idea is that the state of a computation can be represented as a graph, further steps in that computation can then be represented as transformation rules on that graph. Such rules consist of an original graph, which is to be matched to a subgraph in the complete state, and a replacing graph, which will replace the matched subgraph.
Formally, a graph rewriting system consists of a set of graph rewrite rules of the form
, with
being called pattern graph (or left-hand side) and
being called replacement graph (or right-hand side of the rule). A graph rewrite rule is applied to the host graph by searching for an occurrence of the pattern graph (pattern matching, thus solving the subgraph isomorphism problem) and by replacing the found occurrence by an instance of the replacement graph.
Sometimes graph grammar is used as a synonym for graph rewriting system, especially in the context of formal languages; the different wording is used to emphasize the goal of enumerating all graphs from some starting graph, i.e. describing a graph language - instead of transforming a given state (host graph) into a new state.
Contents |
[edit] Graph rewriting approaches
There are several approaches to graph rewriting. One of them is the algebraic approach, which is based upon category theory. The algebraic approach is divided into some sub approaches, the double-pushout approach (DPO) and the single-pushout approach (SPO) being the most important ones; further on there are the sesqui-pushout and the pullback approach.
From the perspective of the DPO approach a graph rewriting rule is a pair of morphisms in the category of graphs with total graph morphisms as arrows:
(or
) where
is injective. The graph K is called invariant or sometimes the gluing graph. A rewriting step or application of a rule r to a host graph G is defined by two pushout diagrams both originating in the same morphism
(this is where the name double-pushout comes from). Another graph morphism
models an occurrence of L in G and is called a match. Practical understanding of this is that
is a subgraph that is matched from
(see subgraph isomorphism problem), and after a match is found, L is replaced with R in host graph G where K serves as some kind of interface.
In contrast a graph rewriting rule of the SPO approach is a single morphism in the category labeled multigraphs with partial graph morphisms as arrows:
. Thus a rewriting step is defined by a single pushout diagram. Practical understanding of this is similar to the DPO approach. The difference is, that there is no interface between the host graph G and the graph G' being the result of the rewriting step.
There is also a more algebraic-like approach to graph rewriting, based mainly on Boolean algebra and an algebra of matrices, called matrix graph grammars.[1][2]
Yet another approach to graph rewriting, known as determinate graph rewriting, came out of logic and database theory. In this approach, graphs are treated as database instances, and rewriting operations as a mechanism for defining queries and views; therefore, all rewriting is required to yield unique results (up to isomorphism), and this is achieved by applying any rewriting rule concurrently throughout the graph, wherever it applies, in such a way that the result is indeed uniquely defined.
[edit] Implementations and applications
Graphs are an expressive, visual and mathematically precise formalism for modelling of objects (entities) linked by relations; objects are represented by nodes and relations between them by edges. Nodes and edges are commonly typed and attributed. Computations are described in this model by changes in the relations between the entities or by attribute changes of the graph elements. They are encoded in graph rewrite/graph transformation rules and executed by graph rewrite systems/graph transformation tools.
- Tools that are application domain neutral:
- GrGen.NET, the graph rewrite generator, a graph transformation tool emitting C#-code or .NET-assemblies
- AGG, the attributed graph grammar system (Java)
- GP (Graph Programs) is a programming language for computing on graphs by the directed application of graph transformation rules.
- GMTE, the Graph Matching and Transformation Engine for graph matching and transformation. It is an implementation of an extension of Messmer’s algorithm using C++.
- Tools that solve software engineering tasks (mainly MDA) with graph rewriting:
- Mechanical engineering
- GraphSynth is an interpreter and UI environment for creating unrestricted graph grammars as well as testing and searching the resultant language variant. It saves graphs and graph grammar rules as XML files and is written in C#.
- booggie integrates GrGen.NET with a port-based metamodel definition and an OpenGL graph visualization based on Tulip
- Biology
- Design and implementation of a graph grammar based language for functional-structural plant modeling (other domains: graphics, architecture)
- Artificial Intelligence/Natural Language Processing
- OpenCog provides a basic pattern matcher (on hypergraphs) which is used to implement various AI algorithms.
- RelEx is an English-language parser that employs graph re-writing to convert a link parse into a dependency parse.
[edit] See also
[edit] Notes
- ^ Perez 2009 covers this approach in detail.
- ^ This topic is expanded at mat2gra.info.
[edit] References
- Handbook of Graph Grammars and Computing by Graph Transformations. Volume 1-3. World Scientific Publishing
- Perez, P.P. (2009), Matrix Graph Grammars: An Algebraic Approach to Graph Dynamics, VDM Verlag, ISBN 978-3639212556.
- Graph Transformation and Graph Grammars
- Heckel, R. (2006). Graph transformation in a nutshell. Electronic Notes in Theoretical Computer Science 148 (1 SPEC. ISS.), pp. 187-198.
- König, Barbara (December 2004). Analysis and Verification of Systems with Dynamically Evolving Structure. Habilitation thesis, Universität Stuttgart, pp. 65-180.