  The modular decomposition of a graph $G=(V,E)$ does not contain prime modules
if and only if $G$ is a cograph, that is, if no quadruple of vertices induces a
simple connected path $P_4$. The cograph editing problem consists in inserting
into and deleting from $G$ a set $F$ of edges so that $H=(V,E\Delta F)$ is a
cograph and $|F|$ is minimum. This NP-hard combinatorial optimization problem
has recently found applications, e.g., in the context of phylogenetics.
Efficient heuristics are hence of practical importance. The simple
characterization of cographs in terms of their modular decomposition suggests
that instead of editing $G$ one could operate directly on the modular
decomposition. We show here that editing the induced $P_4$s is equivalent to
resolving prime modules by means of a suitable defined merge operation on the
submodules. Moreover, we characterize so-called module-preserving edit sets and
demonstrate that optimal pairwise sequences of module-preserving edit sets
exist for every non-cograph. This eventually leads to an exact algorithm for
the cograph editing problem as well as fixed-parameter tractable (FPT) results
when cograph editing is parameterized by the so-called modular-width. In
addition, we provide two heuristics with time complexity $O(|V|^3)$, resp.,
$O(|V|^2)$.
