theory of graph transformations
University of Bremen 2005-11-25 speaker : Helge Wiemann eMail : hwiemann@tzi.de
theory of graph transformations
1
theory of graph transformations
„Die großartige Schönheit eines Graphen besteht darin, dass er unklare, schwer durchschaubare Rätsel auf ein wunderbares Ding aus Linien und Knotenpunkten reduzieren kann.“
D. Olivastro. Das chinesische Dreieck: die kniffligsten mathematischen Rätsel aus 10000 Jahren. Droemer Knauer, München, 1995, S.273 theory of graph transformations
2
theory of graph transformations
Pacman graph movePacman
killPacman
theory of graph transformations
3
++ topics ++
short repetition and introduction graph rewriting category theory subgraphs graph morphism gluing condition
algebraic approach double-pushout approach (DPO) example DPO comparison between SPO and DPO
theory of graph transformations
single-pushout approach (SPO)
4
++ repetition and introduction ++
graphs for ● representing data structures ● states of concurrent and distributed systems ● states of sets of objects with relations between them important examples: ● flow diagrams ● Petri nets ● UML diagrams ● Entity-Relationship diagrams ● finite automata ● maps (of roads or countries)
theory of graph transformations
5
++ repetition and introduction ++
various kinds: ● directed and undirected ● labeled and unlabeled ● simple and multiple ● with binary edges or hyperedges
to represent complex relations between objects as the basic data structure for transportation and tour planning problems to represent various control flows
theory of graph transformations
6
++ repetition and introduction ++
graph (multiple, directed, edge-labeled) as a system:
G = (V, E, s, t, l)
●
finite set of nodes (V) and edges (E) mapping s,t: E -> V: assigns a source s(e) and target t(e) node to every edge in E mapping l: E -> G: assigns a label to every edge in E
●
●
theory of graph transformations
7
graph rewriting -> category theory
● ●
abstract way to deal with mathematical structures and relationships between them our example : category of graphs a category C consists of: a class ob(C) of objects a class mor(C) of morphisms with a unique source object a and target object b (f: a → b) for every three objects a, b and c: composition: mor(a, b) × mor(b, c) → mor(a, c)associativity: f : a → b, g : b → c and h : c → d then h ○ (g ○ f) = (h ○ g) ○ f identity: 1x : x → x called the identity morphism for x
●
theory of graph transformations
8
graph rewriting -> subgraphs (1)
G is a subgraph of H (G H), if VG VH (all nodes of G exist also in H) EG EH (all edges of G exist also in H) sG(e) = sH(e) (every edge of G has the same source node in H) tG(e) = tH(e) (every edge of G has the same target node in H) lG(e) = lH(e) (every edge of G has the same label in H) obtaining a subgraph G: removing some nodes and edges with the condition that the removal of a node is accompanied by the removal of all its adjacent edges
theory of graph transformations
9
graph rewriting -> subgraphs (2)
● ●
G = (V, E, s, t, l) pair of sets of nodes and edges : X = (VX, EX) in (V, E) optaining subgraph H: H = G – X = (V – VX, E – EX, s', t', l') s'(e) = s(e), t'(e) = t(e) and l'(e) = l(e) for all e in E – EX
G1, G2, G3 are subgraphs of G
theory of graph transformations
10
graph rewriting -> graph morphisms
● ●
given two graphs G and H a graph morphism g: G -> H is a pair of functions – gV: VG -> VH (node mappings) – gE: EG -> EH (edge mappings)
that are structure-preserving
●
the image of G in H is called a match of G in H ➔ the match of G in H according to the morphism g is the subgraph g(G) in H, induced by the pair (g(V), g(E)) possible sequence of morphisms with additional graph F: f: F -> G and g: G -> H yields the morphism g o f: F -> H
11
●
theory of graph transformations
graph rewriting -> gluing condition (1)
●
a match maintains the gluing condition with the following two single conditions:
✔
✔
1) identification condition: two elements x and y of L may only not be mapped injectively, if they will be not deleted by the rule mappings: o(x) = o(y), if x=y or x,y in L ∩ R 2) dangling condition: an edge e of M – g(L) neither has its source node nor its target node in g(L) – g(K). (means: if you delete one node, you have to delete all edges that are adjacent) identification condition + dangling condition = gluing condition
theory of graph transformations
12
graph rewriting -> gluing condition (2)
rule r : graph M :
identification condition ok, but dangling condition hurts:
identification condition and dangling condition ok:
theory of graph transformations
13
graph rewriting -> algebraic approach
● ● ●
●
based upon the category theory (category of graphs) rule-based transformation of graphs as the method to perform local changes on graphs specify formally and visually the semantics of rule-based systems rules to express which part of a graph is to be replaced by another graph
general production p: L -> R
i) valid graph transformation, if the match satifies the gluing condition ii) the action of gluing two graphs is a construction, in the category of graphs and graph morphisms, called pushout
theory of graph transformations
14
graph rewriting -> double-pushout approach (DPO)
● ●
frequently used approach for graph transformations used graph transformation rule: – which parts are replaced by other ones – which kinds of transformations are allowed
formal rule r = (L <- K -> R) or (L
●
K
R)
three graphs: L, K, R
(K is a subgraph of L and R)
●
left-hand side (L), gluing graph (K) and right-hand side (R) DPO-production as a pair (L <- K -> R) of two graphmorphisms in the category of graphs with an interface graph K, where K -> L is injective
15
●
theory of graph transformations
graph rewriting -> double-pushout approach (DPO)
rule p: L -> R graph G match OL: L -> G (satifies the gluing condition) building the temporary graph D as subgraph of G by deleting the matching elements construction of the final graph H by adding of R\L in D
the dangling condition ensures that D is graph
theory of graph transformations
16
graph rewriting -> application example: DPO (1)
given: rule r = (L -> K <- R) and graph M
rule
first step: find match L in M, maintains the gluing condition
theory of graph transformations
17
graph rewriting -> application example: DPO (2)
second step: building a temporary graph Z: Z = M – (g(L) – g(K)
theory of graph transformations
18
graph rewriting -> application example: DPO (3)
third step: building the final transformed graph N: N = Z + (R - K)
theory of graph transformations
19
graph rewriting -> single-pushout approach (SPO)
●
case where the interface graph K is only a set of nodes graphical rule representation without an interface graph by depicting only the graphs L and R
formal rule/production r: L -> R
●
direct derivation as single-pushout from the host graph L to the target graph R with only one rewriting step graph rewriting rule only with a single morphism
●
theory of graph transformations
20
graph rewriting -> comparison between SPO and DPO
✔
DPO is more frequently used than the SPO SPO: direct derivation without an interface graph K between the host graph G and the target graph H SPO operates with no identification + dangling condition !! more powerful than DPO more dangerous because a transformation can destroy the graph, e.g. delete edges DPO operates real structure preserving
✔
✔
theory of graph transformations
21
Any questions left
Thanks for your attention !
theory of graph transformations
22
++ references ++
[1] [2] [3] [4] Grzegorz Rozenberg, edito: Handbook of Graph Grammars and Computing by Graph Transformation. Vol.1: Foundations. World Scientific,Singapore,1997. H.-J. Kreowski, R. Klempien-Hinrichs, S. Kuske: Some Essentials of Graph Transformation. University of Bremen, Department of Computer Science. Bremen H.-J. Kreowski: Formale Sprachen: Graphtransformation. Universität Bremen, Sommersemester 2004 www.wikipedia.de
theory of graph transformations
23