• No se han encontrado resultados

Although NP-hard for several classes of graphs including planar or bipartite graphs of maximum degree four and almost regular graphs of maximum degree four (see Theorem 66), the problem of finding a largest induced matching admits a polynomial time solution on trees [Cam89]. The algorithmic approach of Cameron reduces the problem to that of finding a largest independent set in a graphH that can be defined starting from the given tree. IfG= (V;E)is a tree, the graph H=(W;F)hasjVj 1vertices, one for each edge inGand there is an edge between two members

ofW if and only if the two original edges inGare either incident or connected by a single edge.

Notice thatjFj = O(jVj 2

). Moreover each induced matching inGis an independent set of the

same cardinality inH. Gavril’s algorithm [Gav72] finds a largest independent set in a chordal graph

withnvertices andmedges inO(n+m)time. Since the graphH is chordal, a largest induced

matching in the tree can be found inO(jVj 2

efficient way of finding a maximum induced matching in a tree based on dynamic programming. If

G=(V;E)is a tree we choose a particular vertexr2V to be the root of the tree (and we say that Gis rooted atr). Ifv2V nfrgthen parent(v)is the unique neighbour ofvin the path fromvtor;

if parent(v)6=rthen grandparent(v)=parent(parent(v)). In all other cases parent and grandparent

are not defined. Ifu=parent(v)thenvisu’s child. All children of the same node are siblings of

each other. Let(v)be the number of children of nodev. The upper neighbourhood ofv(in symbols

UN(v)) is empty ifv = r, it includesrand allv’s siblings ifv is a child ofrand it includesv’s

siblings,v’s parent andv’s grandparent otherwise. E(UN(v))is the set of edges inGconnecting

the vertices in UN(v).

Claim 2 IfG=(V;E)is a tree andM is an induced matching inGthenjM\E(UN (v))j1,

for everyv2V.

To believe the claim notice that ifMis an induced matching inG, any nodevin the tree belongs to

one of the following types with respect to the set of edgesE(UN (v)):

Type 1. the edgefv;parent(v)gis part of the matching,

Type 2. eitherfparent(v);grandparent(v)gorfparent(v);wg(wherewis some siblings of v)

belongs to the matching,

Type 3. Neither Type 1. nor Type 2. applies.

The algorithm for finding a largest induced matching in a treeGonnvertices handles an n3matrix Value such that Value[i;t℄is the cardinality of the matching in the subtree rooted atiif

vertexiis of typet.

Lemma 35 IfGis a tree onnvertices, Value[i;t℄can be computed inO(n)time for everyi 2

f1;:::;ngandt=1;2;3.

Proof. LetGbe a tree onnvertices and letrbe its root. We assumeGis in adjacency list repre-

sentation and that some linear time preprocessing is performed to order (using standard topological sort [CLR90, Ch. 23]) the vertices in decreasing distance from the root.

The matrix Value can be filled in a bottom-up fashion starting from the deepest vertices of

G. Ifiis a leaf ofGthen Value[i;t℄=0fort=1;2;3. In filling the entry corresponding to node i2V of typetwe only need to consider the entries for all children ofi,j

1 ;:::;j

1. Value[i;1℄= (i) k =1 Value[j k ;2℄.

Sincefi;parent(i)gwill be part of the matching, we cannot pick any edge fromito one of

its children. The matching for the tree rooted atiis just the union of the matchings of the

subtrees rooted at each ofi’s children.

2. Value[i;2℄= P (i) k =1 Value[j k ;3℄.

We cannot pick any edge fromito one of its children here either.

3. Ifihas(i)children then Value[i;3℄if defined as the maximum between P (i) k =1 Value[j k ;3℄

and a number or terms

s j k =1+Value[j k ;1℄+ X l6=k Value[j l ;2℄

If the upper neighbourhood ofiis unmatched we can either combine the matchings in the

subtrees rooted at each ofi’s children (assuming these children are of type 3) or add to the

matching an edge fromito one of its childrenj

k(the one that maximises s

j k

) and complete the matching for the subtree rooted atiwith the matching for the subtree rooted atj

k(assuming j

k is of type 1) and that of the subtrees rooted at each of

i’s other children (assuming these

children are of type 3).

Option three above is the most expensive involving the maximum over a number of sums equal to the degree of the vertex under consideration. Since the sum of the degrees in a tree is linear in the number of vertices the whole table can be computed in linear time. 2

Theorem 62 MAXINDMATCHcan be solved optimally in polynomial time ifGis a tree.

Proof. The largest between Value[r;1℄, Value[r;2℄and Value[r;3℄is the cardinality of a largest

induced matching inG. By using appropriate date structures it is also possible to store the actual

matching. The complexity of the whole process isO(n). 2

Documento similar