
		Graph Grammars
		==============

GraphEd  implements 1-e(d)NCE  graph grammars (the
letter d stands for directed).


Basics
------

The theoretical definition of graph grammars is

  A * S * P

where a  is  an alphabet   (usually  divided  into
terminals and  nonterminals), S is the start graph
and P is a  the set of productions.    In GraphEd,
there are only productions; S may be any graph.


Productions
-----------

Consider undirected productions.  The idea is that
one  node n  is replaced  by a   (arbitrary,  even
unconnected) subgraph   R.   A  embedding relation
specifies how new edges sre introduced.

Let NL and EL be the set of node and  edge labels,
respectively.  The embedding relation is

conn : nodes(R) x NL x EL -> Bool

Let n' be a neighbour  of n, with  edge e' leading
from  n  to  n',  and  r a  node  of  R.  If  conn
(r,label(n'),label(e')) == TRUE, then  introduce a
new edge from r  to n'. The  new edge is  labelled
e'.

Note  that   nodes r of the    right side  can  be
distinguished individually, whereas  nodes  n'  in
the embedding rules (and their edges  e') can only
be distinguished by their labels. 

For example, if n had edges e1 and  e2 to nodes n1
and n2, with label(e1) = label(e2) and label(n1) =
label(n2), n1/e1  and  n2/e2 cannot be  distuished
further. If  conn(r,label(n1),label(e1))   = TRUE,
thenr will have an edge to n1 *and* n2.

Currently,  there is  no  real distinction between
terminal and nonterminal    labels.  All    labels
starting   with a  capital   label  are considered
terminal, all others nonterminal.

Directed  graphs / productions are  treated  fully
analogous;  the embedding  relatiion is split into
ingoing / outgoing parts.


Graphical Representation
------------------------

A graph grammar production is represented as a
big node (the left side) with the right side
drawin in it.

In the following example, A is replaced by
            b
the graph   |  :
            A
+-----------------+
|A                |
|        b-----------------x
|        |        |
|        A-----------------A
|                 |
+-----------------+

To represent the embedding rules, for each

  conn (r,ln,le)

an edge from r labelled le to a node labelled ln
is drawn. In the example, the embedding rules are

  conn (b,'','x') = TRUE
  conn (A,'','A') = TRUE

(A denotes the node A, 'A' the label A).


(Global) Embeddings
-------------------

There is also a way  to enter 'global' embeddings.
They are drawn similar to  normal productions (the
left side is always labelled embedding), but their
right side is not interpreted as a graph. Instead,
each node in the right side defines (a  part of) a
global embedding relation

conn_global : NL x NL x EL -> bool.

The idea  is that conn_global (nl,nl1,el1) will be
applied  to each node r  labelled nl with the same
effect as conn (r,nl1,el1).

Contrary to local embeddings, global embedding can
distingish all nodes/edges by label only.


Restricted Forms
----------------

GraphEd supports three types of 'restricted' graph
grammars :

- 1-NCE graph grammars : 1-eNCE grammars without
  edge labels.

- NLC graph grammars : 1-NCE graph grammars
  without local embedding rules

- BNLC graph grammars : NLC graph grammars with
  the restriction that the right side must not
  contain edges between nonterminals.

(all forms directed/undirected).

These  grammar classes are  mostly  of theoretical
interest.     For   practical purposes,  1-e(d)NCE
ishighly recommended.

Extensions
----------

Embedding edge labels may be changed using the form

   l1>l2

the embedding edge must match l1; the replaced edge
will have label l2. Thus, conn is extended to

conn : nodes(R) x NL x EL -> Bool * EL

Let n' be a neighbour of n, with edge e' leading
from n to n', label(e') = l1, and r a node of R.
If conn (r,label(n'),label(e')) == TRUE, then
introduce a new edge from r to n'. The new edge
is ** labelled l2 **.

Similar,

  l1<l2

changes the direction and the label.
