The algebraic approach to graph rewriting is based upon category theory. 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 morphisms in the category of graphs and graph homomorphisms between them: r = ( L ← K → R ) {\displaystyle r=(L\leftarrow K\rightarrow R)} , also written L ⊇ K ⊆ R {\displaystyle L\supseteq K\subseteq R} , where K → L {\displaystyle K\rightarrow L} 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 k : K → D {\displaystyle k\colon K\rightarrow D} , where D is a context graph (this is where the name double-pushout comes from). Another graph morphism m : L → G {\displaystyle m\colon L\rightarrow G} models an occurrence of L in G and is called a match. Practical understanding of this is that L {\displaystyle L} is a subgraph that is matched from G {\displaystyle G} (see subgraph isomorphism problem), and after a match is found, L {\displaystyle L} is replaced with R {\displaystyle R} in host graph G {\displaystyle G} where K {\displaystyle K} serves as an interface, containing the nodes and edges which are preserved when applying the rule. The graph K {\displaystyle K} 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 G {\displaystyle G} .
In contrast a graph rewriting rule of the SPO approach is a single morphism in the category of labeled multigraphs and partial mappings that preserve the multigraph structure: r : L → R {\displaystyle r\colon L\rightarrow R} . 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.
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.1
Yet another approach to graph rewriting, known as determinate graph rewriting, came out of logic and database theory.2 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.
Another approach to graph rewriting is term graph 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. 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 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 conference3 focuses entirely on research into term graph rewriting and its applications.
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:
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.
Perez 2009 covers this approach in detail. - Perez, P.P. (2009), Matrix Graph Grammars: An Algebraic Approach to Graph Dynamics, VDM Verlag, ISBN 978-3-639-21255-6 ↩
"A Graph-Oriented Object Model for Database End-User Interfaces" (PDF). https://www.cs.indiana.edu/~vgucht/p24-gyssens.pdf ↩
"TERMGRAPH". http://www.termgraph.org.uk/ ↩