In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, graph transformation, or graph rewriting, concerns the technique of creating a new
graph
Graph may refer to:
Mathematics
*Graph (discrete mathematics), a structure made of vertices and edges
**Graph theory, the study of such graphs and their properties
*Graph (topology), a topological space resembling a graph in the sense of discre ...
out of an original graph algorithmically. It has numerous applications, ranging from
software engineering
Software engineering is a systematic engineering approach to software development.
A software engineer is a person who applies the principles of software engineering to design, develop, maintain, test, and evaluate computer software. The term '' ...
(
software construction
Software construction is a software engineering discipline. It is the detailed creation of working meaningful software through a combination of coding, verification, unit testing, integration testing, and debugging. It is linked to all the othe ...
and also
software verification) to
layout algorithms and picture generation.
Graph transformations can be used as a computation abstraction. The basic idea is that if 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
In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a well-formed formula, formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewr ...
system usually 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
In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact: "either it will or will not be ...
, thus solving the
subgraph isomorphism problem In theoretical computer science, the subgraph isomorphism problem is a computational task in which two graphs ''G'' and ''H'' are given as input, and one must determine whether ''G'' contains a subgraph that is isomorphic to ''H''.
Subgraph isomor ...
) and by replacing the found occurrence by an instance of the replacement graph. Rewrite rules can be further regulated in the case of
labeled graph
In the mathematical discipline of graph theory, a graph labelling is the assignment of labels, traditionally represented by integers, to edges and/or vertices of a graph.
Formally, given a graph , a vertex labelling is a function of to a set ...
s, such as in string-regulated graph grammars.
Sometimes graph grammar is used as a synonym for ''graph rewriting system'', especially in the context of
formal language
In logic, mathematics, computer science, and linguistics, a formal language consists of words whose letters are taken from an alphabet and are well-formed according to a specific set of rules.
The alphabet of a formal language consists of symb ...
s; the different wording is used to emphasize the goal of constructions, like the enumeration of all graphs from some starting graph, i.e. the generation of a graph language – instead of simply transforming a given state (host graph) into a new state.
Graph rewriting approaches
Algebraic approach
The algebraic approach to graph rewriting is based upon
category theory
Category theory is a general theory of mathematical structures and their relations that was introduced by Samuel Eilenberg and Saunders Mac Lane in the middle of the 20th century in their foundational work on algebraic topology. Nowadays, cate ...
. The algebraic approach is further divided into sub-approaches, the most common of which are the ''
double-pushout (DPO) approach'' and the ''
single-pushout (SPO) approach''. Other sub-approaches include the ''sesqui-pushout'' and the ''pullback'' approach''.
From the perspective of the DPO approach a graph rewriting rule is a pair of
morphism
In mathematics, particularly in category theory, a morphism is a structure-preserving map from one mathematical structure to another one of the same type. The notion of morphism recurs in much of contemporary mathematics. In set theory, morphisms a ...
s in the category of graphs and
graph homomorphism
In the mathematical field of graph theory, a graph homomorphism is a mapping between two graphs that respects their structure. More concretely, it is a function between the vertex sets of two graphs that maps adjacent vertices to adjacent verti ...
s between them:
, also written
, where
is
injective
In mathematics, an injective function (also known as injection, or one-to-one function) is a function that maps distinct elements of its domain to distinct elements; that is, implies . (Equivalently, implies in the equivalent contrapositiv ...
. The graph K is called ''invariant'' or sometimes the ''gluing graph''. A ''
rewriting
In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a well-formed formula, formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewr ...
step'' or ''application'' of a rule r to a ''host graph'' G is defined by two
pushout
A ''pushout'' is a student who leaves their school before graduation, through the encouragement of the school. A student who leaves of their own accord (e.g., to work or care for a child), rather than through the action of the school, is consider ...
diagrams both originating in the same
morphism
In mathematics, particularly in category theory, a morphism is a structure-preserving map from one mathematical structure to another one of the same type. The notion of morphism recurs in much of contemporary mathematics. In set theory, morphisms a ...
, where D is a ''context graph'' (this is where the name ''double''-pushout comes from). Another graph morphism
models an occurrence of L in G and is called a ''
match
A match is a tool for starting a fire. Typically, matches are made of small wooden sticks or stiff paper. One end is coated with a material that can be ignited by friction generated by striking the match against a suitable surface. Wooden matc ...
''. Practical understanding of this is that
is a subgraph that is matched from
(see
subgraph isomorphism problem In theoretical computer science, the subgraph isomorphism problem is a computational task in which two graphs ''G'' and ''H'' are given as input, and one must determine whether ''G'' contains a subgraph that is isomorphic to ''H''.
Subgraph isomor ...
), and after a match is found,
is replaced with
in host graph
where
serves as an interface, containing the nodes and edges which are preserved when applying the rule. The graph
is needed to attach the pattern being matched to its context: if it is empty, the match can only designate a whole connected component of the graph
.
In contrast a graph rewriting rule of the SPO approach is a single morphism in the category of
labeled multigraph
In mathematics, and more specifically in graph theory, a multigraph is a graph which is permitted to have multiple edges (also called ''parallel edges''), that is, edges that have the same end nodes. Thus two vertices may be connected by more ...
s and ''partial mappings'' that preserve the multigraph structure:
. Thus a rewriting step is defined by a single
pushout
A ''pushout'' is a student who leaves their school before graduation, through the encouragement of the school. A student who leaves of their own accord (e.g., to work or care for a child), rather than through the action of the school, is consider ...
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.
From the practical perspective, the key distinction between DPO and SPO is how they deal with the deletion of nodes with adjacent edges, in particular, how they avoid that such deletions may leave behind "dangling edges". The DPO approach only deletes a node when the rule specifies the deletion of all adjacent edges as well (this ''dangling condition'' can be checked for a given match), whereas the SPO approach simply disposes the adjacent edges, without requiring an explicit specification.
There is also another algebraic-like approach to graph rewriting, based mainly on Boolean algebra and an algebra of matrices, called ''matrix graph grammars''.
Determinate graph rewriting
Yet another approach to graph rewriting, known as ''determinate'' graph rewriting, came out of
logic
Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the science of deductively valid inferences or of logical truths. It is a formal science investigating how conclusions follow from premises ...
and
database theory
Database theory encapsulates a broad range of topics related to the study and research of the theoretical realm of databases and database management systems.
Theoretical aspects of data management include, among other areas, the foundations of q ...
. 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 Two mathematical objects ''a'' and ''b'' are called equal up to an equivalence relation ''R''
* if ''a'' and ''b'' are related by ''R'', that is,
* if ''aRb'' holds, that is,
* if the equivalence classes of ''a'' and ''b'' with respect to ''R'' ...
), 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.
Term graph rewriting
Another approach to graph rewriting is
term graph
A term graph is a representation of an expression in a formal language as a generalized graph whose vertices are . Term graphs are a more powerful form of representation than expression trees because they can represent not only common subexpression ...
rewriting, which involves the processing or transformation of term graphs (also known as ''abstract semantic graphs'') by a set of syntactic rewrite rules.
Term graphs are a prominent topic in programming language research since term graph rewriting rules are capable of formally expressing a compiler's
operational semantics
Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execu ...
. Term graphs are also used as abstract machines capable of modelling chemical and biological computations as well as graphical calculi such as concurrency models. Term graphs can perform
automated verification
In the context of hardware and software systems, formal verification is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specification or property, using formal metho ...
and logical programming since they are well-suited to representing quantified statements in first order logic. Symbolic programming software is another application for term graphs, which are capable of representing and performing computation with abstract algebraic structures such as groups, fields and rings.
The TERMGRAPH conference
focuses entirely on research into term graph rewriting and its applications.
Classes of graph grammar and graph rewriting system
Graph rewriting systems naturally group into classes according to the kind of representation of graphs that are used and how the rewrites are expressed. The term graph grammar, otherwise equivalent to graph rewriting system or graph replacement system, is most often used in classifications. Some common types are:
*
Attributed graph grammar In computer science, an attributed graph grammar is a class of graph grammar that associates vertices with a set of attributes and rewrites with functions on attributes. In the algebraic approach to graph grammars, they are usually formulated using ...
s, typically formalised using either the
single-pushout approach
In computer science, a single pushout graph rewriting or SPO graph rewriting refers to a mathematical framework for graph rewriting, and is used in contrast to the double-pushout approach
In computer science, double pushout graph rewriting (or DPO ...
or the
double-pushout approach
In computer science, double pushout graph rewriting (or DPO graph rewriting) refers to a mathematical framework for graph rewriting. It was introduced as one of the first algebraic approaches to graph rewriting in the article "Graph-grammars: An al ...
to characterising replacements, mentioned in the above section on the algebraic approach to graph rewriting.
* Hypergraph grammars, including as more restrictive subclasses
port graph grammar
A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as Ha ...
s,
linear graph grammars and
interaction nets.
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:
*
AGG the attributed graph grammar system (
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
)
*
GP 2is 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
Graph matching is the problem of finding a similarity between graphs.Endika Bengoetxea"Inexact Graph Matching Using Estimation of Distribution Algorithms" Ph.
D., 2002Chapter 2:The graph matching problem(retrieved June 28, 2017)
Graphs are comm ...
and transformation. It is an implementation of an extension of Messmer’s algorithm using
C++
C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
.
**
GrGen.NET, the graph rewrite generator, a graph transformation tool emitting
C#-code or .NET-assemblies
*
GROOVE a Java-based tool set for editing graphs and graph transformation rules, exploring the state spaces of graph grammars, and model checking those state spaces; can also be used as a graph transformation engine.
*
Verigraph a software specification and verification system based on graph rewriting (
Haskell
Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
).
* Tools that solve
software engineering
Software engineering is a systematic engineering approach to software development.
A software engineer is a person who applies the principles of software engineering to design, develop, maintain, test, and evaluate computer software. The term '' ...
tasks (mainly
MDA
MDA, mda, or ''variation'', may refer to:
Places
* Moldova, a country in Europe with the ISO 3166-1 country code MDA Politics
* Meghalaya Democratic Alliance (2018), ruling coalition government in the Indian State of Meghalaya led by National Pe ...
) with graph rewriting:
*
eMoflon an EMF-compliant model-transformation tool with support for
Story-Driven Modeling
Story-driven modeling is an object-oriented modeling technique. Other forms of object-oriented modeling focus on class diagrams.
Class diagrams describe the static structure of a program, i.e. the building blocks of a program and how they relate ...
and Triple Graph Grammars
*
EMorFa graph rewriting system based on
EMF, supporting in-place and model-to-model
transformation
Transformation may refer to:
Science and mathematics
In biology and medicine
* Metamorphosis, the biological process of changing physical form after birth or hatching
* Malignant transformation, the process of cells becoming cancerous
* Trans ...
*
Fujabauses Story driven modelling, a graph rewrite language based on PROGRES
**
Graph databases
A graph database (GDB) is a database that uses graph structures for semantic queries with nodes, edges, and properties to represent and store data. A key concept of the system is the ''graph'' (or ''edge'' or ''relationship''). The graph relat ...
often support dynamic rewriting of graphs
**
GReAT
Great may refer to: Descriptions or measurements
* Great, a relative measurement in physical space, see Size
* Greatness, being divine, majestic, superior, majestic, or transcendent
People
* List of people known as "the Great"
*Artel Great (born ...
*
Gremlin a graph-based programming language (se
Graph Rewriting
*
Henshin a graph rewriting system based on
EMF, supporting in-place and model-to-model
transformation
Transformation may refer to:
Science and mathematics
In biology and medicine
* Metamorphosis, the biological process of changing physical form after birth or hatching
* Malignant transformation, the process of cells becoming cancerous
* Trans ...
,
critical pair analysis, and
model checking
In computer science, model checking or property checking is a method for checking whether a finite-state model of a system meets a given specification (also known as correctness). This is typically associated with hardware or software systems ...
*
PROGRES an integrated environment and very high level language for PROgrammed Graph REwriting Systems
**
VIATRA
VIATRA
is an open-source model transformation framework based on the Eclipse Modeling Framework (EMF) and hosted by the Eclipse Foundation.
VIATRA supports the development of model transformations with specific focus on event-driven,
reactive t ...
* Mechanical engineering tools
*
GraphSynthis 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
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
files and is written in
C#.
*
Soley Studio is an
integrated development environment
An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
for graph transformation systems. Its main application focus is data analytics in the field of engineering.
* Biology applications
*
Functional-structural plant modeling with a graph grammar based language*
Multicellular development modeling with string-regulated graph grammars* Artificial Intelligence/Natural Language Processing
**
OpenCog
OpenCog is a project that aims to build an open source software, open source artificial intelligence framework. OpenCog Prime is an architecture for robot and virtual embodied cognition that defines a set of interacting components designed to giv ...
provides a basic pattern matcher (on
hypergraph
In mathematics, a hypergraph is a generalization of a graph in which an edge can join any number of vertices. In contrast, in an ordinary graph, an edge connects exactly two vertices.
Formally, an undirected hypergraph H is a pair H = (X,E) wh ...
s) which is used to implement various AI algorithms.
*
RelExis an English-language parser that employs graph re-writing to convert a
link parse into a
dependency parse.
* Computer programming language
** The
Clean programming language is implemented using graph rewriting.
See also
*
Graph theory
In mathematics, graph theory is the study of ''graphs'', which are mathematical structures used to model pairwise relations between objects. A graph in this context is made up of '' vertices'' (also called ''nodes'' or ''points'') which are conne ...
*
Shape grammar
*
Formal grammar
In formal language theory, a grammar (when the context is not given, often called a formal grammar for clarity) describes how to form strings from a language's alphabet that are valid according to the language's syntax. A grammar does not describe ...
*
Abstract rewriting
In mathematical logic and theoretical computer science, an abstract rewriting system (also (abstract) reduction system or abstract rewrite system; abbreviated ARS) is a formalism that captures the quintessential notion and properties of rewriting s ...
— a generalization of graph rewriting
References
Citations
Sources
* .
* .
* Heckel, R. (2006). ''Graph transformation in a nutshell''
Electronic Notes in Theoretical Computer Science148 (1 SPEC. ISS.), pp. 187–198.
* König, Barbara (2004). ''Analysis and Verification of Systems with Dynamically Evolving Structure''
Habilitation thesis, Universität Stuttgart pp. 65–180.
*
*
*
*
{{refend