Edge mutation in EGGP consists of 4 steps:
1. Pick an edge to redirect uniformly at random.
2. Identify all nodes for which there is a path from that node to the source of the chosen edge. If the edge were redirected to target these nodes, then a cycle would be created. 3. Redirect the chosen edge to target some node for which there is no such path.
4. Remove any annotations made in the graph by step 2.
We present a P-GP 2 program implementing this mutation in Figure 5.7. It should be stressed that in general, such a program works on the assumption that the host graph is unmarked. Each of the commands called sequentially corresponds to a step of the process outlined above:
i i o
This individual is to undergo an edge mu- tation preserving acyclicity.
i i
o (1) pick edge:
An edge to mutate is chosen at random and marked (red) alongside its source node s (blue) and target node t (red).
i i
o (2) mark output!:
Invalid candidate nodes for redirection are identified. If a node v has a directed path to s it is marked blue, as targeting it would introduce a cycle.
i i
? o (3) mutate edge; unmark!:
The edge e is mutated to target some randomly chosen unmarked (non-output) node, preserving acyclicity. The new tar- get has been marked with a star ‘?’ for visual clarity. Finally, all marks are re- moved.
Figure 5.8: A trace of the application of the edge mutation program in Figure 5.7. For visual simplicity, node and edge labels have been omitted.
1. The rule pick_edge chooses an edge uniformly at random. Its source is marked blue and its target is marked red to uniquely identify them. Additionally, the edge itself is marked red to avoid any confusion with parallel edges.
2. The rule mark_output called as long as possible ensures all nodes with paths to the source of our chosen edge are marked blue. As a consequence, redirecting the edge to target and blue node would introduce a cycle, whereas redirecting the edge to target any unmarked node would not.
3. The rule mutate_edge redirects the edge to target some unmarked node. Not only does this avoid introducing a cycle, but the fact that the target of the chosen edge is red ensures that the mutation always produces a change.
4. The rule unmark called as long as possible removes the blue marks created by step 2. We give an example execution of our mutation in Figure 5.8. In this diagram, all node and edge labels are not shown to aid visual clarity and to stress that this mutation depends only on the topology of the graph and effectively ignores labels.
Correctness
Here we present an outline of a proof that the edge mutation is correct in the sense that, when presented with an unmarked AFG as an input graph, the edge mutation can only produce AFGs as output graphs.
The overall correctness is a simple argument; if there exists a path v1 → v2, then creating
an edge, v2 → v1, clearly creates a cycle, v1 → v2→ v1. In contrast, if there is no such path,
v1 → v2, then it is clear that creating an edge, v2 → v1, cannot create such a cycle. Hence
the correctness of our program depends on the correctness of the claim in step 2, that the application of mark_output as long as possible causes all nodes for which there is such a path to become marked blue. To see that the claim in step 2 is true, we can use a simple proof by induction on the length of paths to the source of the chosen edge:
Lemma 1 (Correctness of Edge Mutation.). Let G be an unmarked AFG, and G ⇒pick_edge
H be a valid derivation and e be the single red marked edge in G. Then for any D = (V, E, lV, lE, s, t) with H ⇒mark_output! D, it holds that
Proof of Lemma 1. Base case n = 1:
For all v ∈ V, if an edge v → s(e) exists then v is blue. (5.4) where an edge v → s(e) is equivalent to a path v → s(e) of length 1.
Now suppose this base case did not hold; then there would be some node, vx ∈ V , for which
there existed an edge, vx → s(e), and vx is not marked blue. As G is acyclic and no edges
have been added in G ⇒ H ⇒∗ D, it is clear that vx 6= t(e) as this would imply a cycle. As
G is unmarked, and only 1 edge has been marked by the single call to pick_edge, it follows that the edge, vx → s(e), must be unmarked. Further, as vx is not blue and vx 6= t(e), vx
must be unmarked as G is unmarked and no other marks are introduced by pick_edge or mark_output.
As no blue marked nodes are unmarked or remarked by mark_output it must hold that: 1. s(e) is marked blue.
2. The edge vx→ s(e) must be unmarked.
3. vx must be unmarked.
Then it is clear that there exists a match for mark_output with node 2 matched to s(e) and node 1 matched to vx. Hence we have a contradiction with H ⇒mark_output!D and it follows
that vx cannot exist.
Inductive Hypothesis n = k: Assume that for n = k:
For all v ∈ V, if a path v → s(e) of length k exists then v is blue. (5.5)
Inductive step n = k + 1: Consider a node vx such that
There exists a path of length k + 1, vx→ s(e), and vx is not marked blue. (5.6)
As G is acyclic and no edges have been added in G ⇒ H ⇒∗ D, it is clear that vx6= t(e) as
this would imply a cycle. As G is unmarked, and only 1 edge has been marked by the single call to pick_edge, it follows that all edges in the path edge, vx → s(e), must be unmarked.
Further, as vx is not blue and vx 6= t(e), vx must be unmarked as G is unmarked and no
other marks are introduced by pick_edge or mark_output.
For such a path of length k + 1 to exist it is clear that there must exist some vy where
there is an edge, vx → vy, and a path of length k : vy → s(e). By our inductive hypothesis,
1. vy is marked blue.
2. The edge vx→ vy must be unmarked.
3. vx must be unmarked.
Once again it is clear that there exists a match for mark_output with node 2 matched to vy and node 1 matched to vx. Hence we have a contradiction with H ⇒mark_output!D and it
follows that vx cannot exist.
Hence for all n ≥ 1, it holds that
For all v ∈ V, If a path v → s(e) of length n exists then v is blue. (5.7)
Hence it is clear that our edge mutation preserves acyclicity. Further, the only relabelling of nodes to take place is in the marks, and all marks are removed, it is clear that all node labels are unchanged by the edge mutation. Additionally, the only modified edge is that chosen by the rule pick_edge, and this is simply marked, unmarked and redirected. In combination, these facts guarantee that, when presented with an unmarked AFG, the edge mutation always produces an AFG e.g. is correct with respect to the domain we are interested in.