In Figure 1 the
start graph of grammar ShortestPath.ggx is depicted, consisting of some cities connected by roads.
The rules of the grammar are shown
in Figures 22 - 30.
Transformation options chosen for our example are injective matches which satisfy the dangling condition, rules with NACs, the completion strategy CSP and layered rules as shown in Figure 32.
To determine a start and a goal city, we have to define a partial match of rule start by mapping the two cities at the left-hand side. After completing this partial match and applying the rule, the transformation result is shown in Figure 33.
The match defines city to be the
start and city to be the goal of the search. Additionally,
rule start defines a maximal distance between start and
goal cities. This is done by a node where attribute
max is set to 10.
Figure 34 shows the host graph after applying rule
expandStart three times. Three possible matches of this rule realize the expansion of the
start city: for all three neighbours the corresponding edges are generated. The newly generated edges carry the start information of the paths with length from City to City .
In Figure 35, we see the host graph after applying rule expand nine times. New edges are generated to all possible cities on the way to the goal. The path lengths have been raised. This rule has an attribute condition that forbids to follow a path with a new length longer then max m. Four NACs of this rule prevent: 1. the current city is a start city, 2. the current city is a goal city, 3. the next city is a start city, 4. the path to the next city is already expanded.
The next rule to apply is expandMore. That rule compares already computed path
lengths and takes the smallest as a best possible path.
The NACs of the rule
prevent: 1. the current city is a start city, 2. the current city is a goal city, 3. the next city is a start city.
In our example this rule is not applicable for chosen the
- pair of cities.
Now the rule setMax is applicable. In Figure 36, we can see the host graph where attribute max of node State is changed from 10 first to 9 and then to 7.
Finally, Figure 37 shows the host graph after applying showRoad and showRoad1. Rule showRoad marks the last part of the path from start to goal cities and rule showRoad1 marks the next part of the path backwards.
Figure 37 shows a successful result of
the execution of our grammar.
You can see the shortest path
from to city with length :
A - G - H with State max=7.