Cographs may be recognized in linear time, and a cotree representation constructed, using
modular decomposition,
partition refinement,
LexBFS , or
split decomposition. Once a cotree representation has been constructed, many familiar graph problems may be solved via simple bottom-up calculations on the cotrees. For instance, to find the
maximum clique in a cograph, compute in bottom-up order the maximum clique in each subgraph represented by a subtree of the cotree. For a node labeled 0, the maximum clique is the maximum among the cliques computed for that node's children. For a node labeled 1, the maximum clique is the union of the cliques computed for that node's children, and has size equal to the sum of the children's clique sizes. Thus, by alternately maximizing and summing values stored at each node of the cotree, we may compute the maximum clique size, and by alternately maximizing and taking unions, we may construct the maximum clique itself. Similar bottom-up tree computations allow the
maximum independent set,
vertex coloring number, maximum clique cover, and Hamiltonicity (that is the existence of a
Hamiltonian cycle) to be computed in linear time from a cotree representation of a cograph. Because cographs have bounded clique-width,
Courcelle's theorem may be used to test any property in the monadic second-order
logic of graphs (MSO1) on cographs in linear time. The problem of testing whether a given graph is
k vertices away and/or
t edges away from a cograph is
fixed-parameter tractable. Deciding if a graph can be
k-edge-deleted to a cograph can be solved in O*(2.562
k) time, and
k-edge-edited to a cograph in O*(4.612
k). If the largest induced cograph subgraph of a graph can be found by deleting
k vertices from the graph, it can be found in O*(3.115
k) time. Two cographs are
isomorphic if and only if their cotrees (in the canonical form with no two adjacent vertices with the same label) are isomorphic. Because of this equivalence, one can determine in linear time whether two cographs are isomorphic, by constructing their cotrees and applying a linear time isomorphism test for labeled trees. If
H is an
induced subgraph of a cograph
G, then
H is itself a cograph; the cotree for
H may be formed by removing some of the leaves from the cotree for
G and then suppressing nodes that have only one child. It follows from
Kruskal's tree theorem that the
relation of being an induced subgraph is a
well-quasi-ordering on the cographs. Thus, if a subfamily of the cographs (such as the
planar cographs) is closed under induced subgraph operations then it has a finite number of
forbidden induced subgraphs. Computationally, this means that testing membership in such a subfamily may be performed in linear time, by using a bottom-up computation on the cotree of a given graph to test whether it contains any of these forbidden subgraphs. However, when the sizes of two cographs are both variable, testing whether one of them is an induced subgraph of the other is
NP-complete. Cographs play a key role in algorithms for recognizing
read-once functions. Some
counting problems also become tractable when the input is restricted to be a cograph. For instance, there are polynomial-time algorithms to count the number of
cliques or the number of maximum cliques in a cograph. ==Enumeration==