Vous êtes sur la page 1sur 5
A Survey of Graph Grammars: Theory and Applications Heda Fahmy and Dorothea Blostein Department of Computing & Information Science (Queen's University. Kingston, Ontario, Canada. K7L 3N6 faimyh@ qucis.qucensuca,bostein@ qucis.queensu.ca Abstract Graph grammars provide a useful formalism for describing structural manipulations of multi- 2,6) and auntie paps which may have labeled des andlor edges. () species an embedding (Section 4), Optional producton-rale components include ausibele computation rules and applicability predicates ‘The grap o which a production is being applid. ae ‘A subaraph of g whichis isomorphic 0 gy ResiGaaoh ‘The graph that remains fiers) is removed from g. (AII nodes and edges of g(™* are removed. This includes edges with one endpoint ing) [A raph isomorphic to, used to replace gy ‘The set of edges hetwoon RestGraph and g:>™, ‘The set of edges between ResiGraph and g,ho Uncomplicated embedding mechanisms establish a correspondence the pre-embedding edges and the post- ‘embedding edges Section 3). "Asubgraph gh" is located and removed from g. This involves an expensive subgraph-isomorphism test) Next gis added to ResiGraph, nd post-embedding edges (between 2° and RestGraph) ae formed according wo (E). Graph-rewrtng can be sequential or parallel [NagI79} (Nagl87). In tis paper we consider Sequential rewriting: during given derivation step only one gi subgraph i rewriten. Atibutes ‘Attibules, associated with graph nodes andor edges, encode non-structural or semantic information, “Altibute values may be of any type including integers, reals text and Hiss Atribule Transfer Function For graph grammars that process attributed graphs every production is augmented by an attribute transfer function [Bunk823], Initially g,P°* is a duplicate of the ‘unattributed graph g,, The attribute transfer function assigns attribute values to the nodes andor edges in «and posibly als tothe embedding edges, Anolicablity predicate (or “aplication condition”) ‘Production rules optionally include applicability predi- cates fo express conditions on the host graph that must hold in order for 5)" 10 be replaced by g,Fe! [Bunk32a}. These conditions, which cannot be tested by subgraph matching alone, include constraints on = ‘tribute valves, as well 5 tests forthe non-existence of an edge (EhF186 F102). Programming a grammar adds a contol mechanism for ordering the application of productions. programmed ‘grammar no longer relies on the distinction between {erminals and non-terminals to control the termination of a derivation, Programmed string grammars were introduced in (Rose69]; Bunke generalized this to graph ‘grammars in 1974 (see (Bunk826). Programming is ‘expressed via a control diagram, which specifics the set ‘of productions to try next, conditional onthe successful fr failed application of the current production. [Extensions to the basic contro-diagram notation include ‘conditional branches based on attribute values [DoToS8}, controlled backtracking in case of unsuccessful ondeterministic subgraph selections [ZUSe91], subgrammars and “non-programmed” grammar sections ((FaBI92] and Figure 1). Programming a graph grammar can support grammar — modularization (Bunk82a][FaB192}, but it does not increase the generative power of the grammar [Bunk82b]. (By ‘contrast, a programmed context-free string grammar can generate a context sensitive language [Fu82],) Spee a Figure 1 Control diagram notation to make expli ‘on-programmed grammar sections. This control diagram specifies the sequence: apply productions PI and P2, in any order oF concurrently, as often as possible; then apply 3 as often as possible. 3. The Embedding Problem ‘The various approaches to graph grammars differ ‘mainly in the way the embedding transformation is defined. A tradeoff can be made between the power ofan embedding mechanism, and the complexity of the embedding specification. At one extreme, we have the expression embedding mechanism developed by [Nagl79]: this very powerful but highly complex meckanism illyteated in Figure 2. A simpler mechanism is ilutrated in Figure 3, The power of an embedding mechanism depends onthe ability to specify the embedding in terms of. node labels, edge labels, edge directions, and edge following. This observation is formalized by Nagl’s classification of embedding mechanisms ((Nagl79] and [Nagl87)). The following classes are defined, from most ‘complex to least complex. + Unrestricted ~ Unrestricted embeddings can be expressed by the expression approach illustrated in Figure 2, Starting at any g* node, we can follow a sequence of edges (stating with a pre-embedding edge), conditional ‘on edge orientations and edge labels, ending a a set of ResiGraph nodes. A subset of these nodes can be chosen (based on node label) to act as sourcetarget nodes for post-embedding edges. The directions and edge-labes ofthe postembodding edges can be chosen fealy. Orientation and Label Preserving — Embedding ‘manipulations have to preserve orientation and labels of ‘embedding edges. Using the Figure 2 notaion, this ‘means thatthe set In; has to begin by following an T, ‘edge the set Out; has to begin by following an O edge. Depth - The rest-graph nodes which are soure/target ‘nodes of post-embedding edges ar restricted to the direct neighbors of gh", Post-embedding edges with various ‘orientations and labels can be constructed, conditional on the labels of nodes that are direct neighbors of g)". A, ‘well-known example ofa Deptht embedding mechanism is Neighborhood Controlled Embedding (NCE), defined bby JaRo82]. NCE applis the additional restition that the embedding is orientation-preserving (but not necessarily lbel-preserving). ws Ky Lo Embedding transformation: In;= (Dlx O, (1:34) Ou = G0; 2) (2) the production rule (©) initial host graph (@) estan raph Figure 2. Illustration of the expression embedding mechanism defined by [NagI79: the production of part (2), applied tothe host graph (b), produces the result (e)- Ih embeds incoming eilges of label i, and Out embeds ‘outgoing edges of label j. In, specifies thatthe set of nodes “D ly; (1)" are source nodes of ‘labelled edges ending in nodes 3 and 4 ofg0", ‘The expression “D f, ()” describes the following set of nodes: starting from node 1 of s fllow an outgoing edge with label j (0) and then an incoming edge with label K(); include those ‘nodes that have the label D. Similarly, Out specifies that the set of nodes 0} U Ty ly (1.2) ar target nodes of j- labelled edges originating in’ node 3 of gy". The expression “O, Uy (1.2) dseries the following set of nodes: starting from nodes I or 2 of 2), follow a chain ‘of two incoming edges with label k oF one outgoing edge with abe ‘Simple - Depth, and Orientation and Label Preserving, Elementary ~ Simple, with the following aditional restriction. Selection of source / target nodes of past embedding edges mast be independent ofthe noe labels of g's direct neighbors. The first formaly-detined embedding mechanism (veloped by Schneier in 1970, summarized in {NagI79)}) was ofthe Blementary ype Analogous ~ Elementary, and the embedding transformation is independent of the orientations and labels of embedding edges. Figure 3 illustrates an embedding of this type: note the spliting of a pre- ‘embedding edge into two postembedding edges. 3 z cae z Gea) CG=) # Qed) Embedding transformation: {(1,1), (2.29, G3). (14) Figure 3 Illustration of an embedding mechanism classified as analogous by {Nagl87). The embedding specifies that an edge incident on node 1 of gh" is tansformed ino two edges, incient on nodes 1” and” of 4.8. An edge incident on node 2 is transformed into an cele incident on node 2°; similarly a node-3 edge is transformed into a node edge. ‘This production, from the (FaBI92] music-recogntion srammar, duplicates doubly-stemmed noicheads 10 allow ‘subsequent processing as two independent notes. z + Invariant ~ Nodes of gare mapped to nodes of g,: this ‘mapping controls the transfer of embedding edges from the g}® nodes to the coresponding g,% nodes. This type of embedding does not allow edge splitting or fusion during the embedding proces. The expression embedding mechanism (Figure 2) is powerful since the host graph canbe extensively ‘manipulated by applying a single production. The complex expressions allow the following of edge sequences within RestGraph, as wel as node-label based selection of source or target nodes for post-embedding edges. However, formulating such generalized expressions is extremely difficult and often not intellectually manageable. In practice it can be preferable fo restrict a graph-grammar to 4 Tess complex embedding mechanism, such a5 the one illustrated in Figure 3. A less powerful embedding ‘mechanism is more intellectually manageable, and often sulfies for expressing the graph-manipulations required for 2 given application. ‘The class of graph languages generated by a graph grammar is dependent not only upon the type of production used, but also upon the type of embedding ‘mechanism employed. For example, given the use of an ‘expression embedding mechanism, the same graph languages are produced by monotone, context-sensitive, and context-free graph grammars (Figure 4). These Aiffering restrictions on the complexity of gy donot affect the power of the graph grammar because the embedding expressions allow introduction of context-dependency during the embedding process itself [Recursively enumerable gray fexpression-unrestricted] U expression-monotone] ‘context-sensitive] = lexpression-context-free] U {expression-linear] = [expression-regular] Figure 4 ‘The hierarchy for graph languages generated by ‘graph grammars using the expression embedding ‘mechanism (Nagl79], Production types are defined as follows (assuming a distinction between terminal and ronterminal node labels) + unrestricted prodvction —no restriction on g oF B, + monotone production - the number of nodes in gis less than or equal to the numberof nodes in context-sensitve production ~a potion of g exist as a subgraph off, context free production ~ 8, consist of exactly one node. (Mis node has a nontermina abel.) linear production ~a restricted context-free production, ‘where g, contains at most one nonterminally-labeled rode (pls any naraber of terminally-labeled nodes) ‘regular production ~a restricted context-free production, ‘where g, has a unigue maximum node; all other g, nodes are predecessors of the maximum node. The ‘maximum node may have a terminal or non-terminal label al other g, nodes have terminal labels. 4. Applications Graph grammars were first introduced in [PTRO69] to solve picture processing problems. A picture can be represented as a graph, where labelled nodes represent ‘primitives, and labelled edges represent geomet relations (uch as is right of is below). Graph grammars would ‘seem {0 be a suitable tool for parsing and generating classes of such pictures. Although picture processing problems initiated the investigation of graph grammars, the results of graph-grammar research have been more extensively used in other fields. Here we survey graph- ‘grammar use for picture processing, and give brief mention to other application areas. For futher information, refer 10 WGGE7| and {TWGG1}), particularly (Panel). Graph grammars have been applied to diagram recognition [Pfal72][Bunk82s][FaB192), The NRNTST system of [Pfal72] uses graph grammars to parse “neural network” pictures. » [Bunk82a) discusses how attributed programmed graph grammars can be used to interpret schem: diagrams and flowcharts. Bunke suggests that graph grammars be used not for parsing, but rater to transform ‘an input graph into an output graph. This helps overcome the parsing inefficiency associated with graph grammars. ‘The method is applied to transforming a two-dimensional arrangement of lines (derived, for instance, from a ciruit

Vous aimerez peut-être aussi