• No results found

For the application of graph transformation rule to a graph, we need a technique to glue graphs together along a common subgraph, Intuitively, we use this common subgraph and add all other nodes and edges from both graphs. The idea of a pushout generalizes the gluing construction in the sense of category theory, i.e. a pushout object emerges from gluing two objects along a common subobject.

3.4.1 Gluing Condition

Within the algebraic approach and the application of graph transformation, we will only have a valid graph transformation if the match of the left graph Lof the rule of transformation in the given graphGsatisfies the gluing condition. The gluing condition is verified if and only if the two sub conditions are valid:

• The identification condition, this condition will be satisfied if two different elements x and y of the left graph L either are mapped injectively (none two different elements of the definition quantity are mapped to the same element of the target quantity) or may only not be mapped injectively if these two elements are not deleted by the transformation rule. FormallyO(x) =O(y)only ifx=yorx, y∈LT

R

• The dangling condition, this condition will be satisfied if an edgeeofM −g(L)neither has its source node nor its target node ing(L)−g(K). That means that, if we delete one node, we have to delete all edges that are adjacent to this node.

The addition of these two sub conditions forms the gluing condition [Kwo00]

3.4.2 Double-Pushout Approach DPO

The double−pushout approach, shortly called DPO, is a sub approach of the algebraic approach and is the frequently used approach for graph transformations. The DPO adopts a specific rule for the graph transformation which answer two important questions in graph transformations:

• which parts are replaced by which other? • which kinds of transformations are allowed?

From the perspective of the DPO a graph rewriting rule is a pair of morphisms in the category of graphs with total graph morphisms as arrows, specified by the formal ruler = (L←K →R).

The graphsLandRare respectively called as we already also mentioned, the left-hand side and the right-hand side of the rule. The graphK is often called gluing graph or interface graph. A rewriting step with the application of the DPO−production is defined as a pair(L← K →R)

or(L⊇ K ⊆R)of two graph morphisms as arrows in the category of graphs with an interface graphK, whereK →Lis injective. Because of that the interface graphK is a real subgraph of Las well as of R [CER79, EKRR91]. A rule applicationr = (L ⊇ K ⊆ R)can be depicted

L R

L R

G OL

Figure 3.15: Mechanism to find a match

by the following diagrams. They will illustrate the formal step of a graph rewriting and will describe why this approach is calleddouble−pushoutapproach. The gluing graphKis rightly described in the diagrams as L ∩R (see Fig. 3.15). The graph morphism OL in the shown

L R L R L R G D O OL

Figure 3.16: building the temporary graph

diagram models an occurrence ofLinGand is called the match. Practical understanding of this is thatLis a subgraph that is matched fromGand after a match is found, the left side of the rule

(L)is replaced by the right side of the rule(R)in the host graphGwhereKasL∩Rserves as some kind of interface.

L R

L R

L R

G D H

OL O OR

Figure 3.17: construction of the final graph

If a match is found (see Fig. 3.15) there are two steps to achieve the graph rewriting. First you have to build a temporary graph (D) as a subgraph of the host graph G by deleting the matching

elements7 (figure 3.16). Finally we have to build the final transformed graphH by adding the

elements ofR−LT

Rto the built temporary graph D (see Fig. 3.17). Formally:

• The single graph morphisms OLT

R : L

T

R → D and OR: R → H are given by

OLT R(v) =OL(v)for allv ∈VLT R • OLT R(e) = OL(e)for alle ∈ELT R • OR(v) =OL T R(v)ifv ∈VL T R. • OR(v) =v ifv ∈VR−VLT R • OR(e) =OLT R(e)ife∈ELT R • OR(e) =eife∈ER−ELT R [KKHK].

3.4.3 Single-Pushout Approach SPO

In contrast to the recently mentionedDP O, a graph rewriting rule of theSP Oapproach is only a single morphism and therefore only a single derivation of the host graphGwith context again to the category of graphs.

TheSP Ois often used in cases where the interface graphKas in theDP Ois only a set of nodes but without any adjacent edges. Then we do not have to look at the edges for the graph rewriting step. We can use the graphical rule representation without an interface graph by depicting only the graphs LandR. Thus a rewriting step is only defined by a single pushout diagram with a single graph morphism as arrows as the formal rule (production)r:L→R [AGG].

L H p m m* p* R G

Figure 3.18: building the temporary graph

Figure 3.18 illustrate the practical understanding of the SPO. We perform the rewriting step only a single derivation (morphism) as a single−pushout from the host graphLto the target graphR.

Definition (Graph Transformation) Given a (typed) graph productionp = (L ←l K r

R) and a (typed) graph G with a (typed) graph morphism m : L ← G, called the match, a direct (typed) graph transformation G ⇒p,m H from Gto a (typed) graphH is given by the

following double-pushout (DPO) diagram, where (1) and (2) are pushout in the categoryGraphs orGraphsT G, respectively :

K

L

R

G

D

H

l f (1) k (2) n r m g

A sequence G0 ⇒ ... ⇒ Gn of direct (type) graph transformations is called a (typed) graph

transformation and is denoted byG0 ⇒∗ Gn. Forn = 0, we have the identical (typed) graph

transformationG0 ∼=G

0

0, because pushout and hence also direct graph transformations are only

unique up to isomorphism.

The application of a production to a graph G can be reversed by it’s inverse production. The result is equal or at least isomorphic to the original graphG

Definition (Graph Language) A graph transformation systemGT S = (P) consists of a set of graph productionsP.

A typed graph transformation systemGRS = (T G, P)consists of a type graphT Gand a set of typed graph productionsP.

A (typed) graph grammarGG = (GT S, S) consists of a (typed) graph transformation system GT S and a (typed) start graphS.

The (typed) graph languageLofGGis defined byL={G|∃(typed) graph transformationS →∗

G} We shall use the abbreviation ”GT system” for ”graph and typed graph transformations system”.