After locating a happy clique C in
we
need to search it for a vertex with a maximum number
of unoriented neighbors. In this section we give an algorithm
that performs this task.
Let
be the intervals in C
ordered in increasing left endpoint order.
Clearly,
.
Thus the endpoints of the j vertices in C partition the
line
into 2j+1 disjoint intervals
,
where
,
Il=(L(l),L(l+1)] for
,
Ij=(L(j),R(1)],
Il=(R(l-j),R(l-j+1)] for
j < l < 2j
and
.
The algorithm consists of the following three stages.
Stage 1:
Let e be an unoriented vertex
that has a non-empty intersection
with the interval
[L(1),R(j)]. Mark each of e's endpoints
with the index of the interval that contains it. Stage 2:
Let o be an array of j counters, each corresponding
to a vertex in C.
The intention is to assign values to o such that
the sum
is the unoriented degree
of the vertex .
The counters are initialized to zero. For each unoriented vertex e
that overlaps
with the interval
[L(1),R(j)] we change at most four of the
counters as follows.
Let Il and Ir be the intervals in which L(e) and R(e)
occur, respectively. We may assume l < r as otherwise e
is not adjacent to any vertex in C and we can ignore it.
We continue according to one
of the
following cases. Case 1:
.
All the vertices from el+1 to
er are adjacent to e:
we increment o[l+1] and decrement o[r+1] (if r<j). Case 2:
.
All the vertices from el-j+1 to er-j
are adjacent to e:
we increment o[l-j+1] and decrement o[r-j+1] (if r < 2j). Case 3:l < j and j < r.
Let
.
If m > 0 then
all the vertices from e1 to em are adjacent to e:
we increment o[1] and decrement o[m+1].
Similarly let
.
If M < j then the vertices
from el+1 to ej are adjacent to e: we increment the counter
o[l+1]. Stage 3: Compute
.
Return ef.
The following theorem summarizes the result of this section.
Theorem 11.15
Given a clique C, the vertex
computed by the algorithm above
has maximum unoriented degree among the vertices in C.