next up previous
Next: Algorithm Summary Up: An Algorithm for Sorting Previous: Finding a Happy Clique

   
Computing the Unoriented Degrees

After locating a happy clique C in $OV(\pi )$ we need to search it for a node with a maximum number of unoriented neighbors. In this section we give an algorithm that performs this task.

Let $e_{1},\ldots,e_{j}$ be the intervals in Cordered in increasing left endpoint order. Clearly, $L(1) < L(2) < \ldots < L(j) < R(1) < R(2) < \ldots < R(j)$. Thus the endpoints of the j vertices in C partition the line into 2j+1 disjoint intervals $I_0,\ldots ,I_{2j}$, where $I_0=(-\infty, L(1)]$, Il=(L(l),L(l+1)] for $1\le l < j$, Ij=(L(j),R(1)], Il=(R(l-j),R(l-j+1)] for j < l < 2jand $I_{2j}=(R(j),\infty)$. The algorithm consists of the following three stages.

Stage 1: Let e be an unoriented node 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 node in C. The intention is to assign values to o such that the sum $\sum_{i=1}^l o[i]$ is the unoriented degree of the node $e_l\in C$. The counters are initialized to zero. For each unoriented node 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 eis not adjacent to any node in C and we can ignore it. We continue according to one of the following cases.
Case 1: $r \le j$. 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: $j \le l$. All the vertices from el-j+1 to er-jare 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 $m=\min\{l, r-j\}$. 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 $M=\max\{l,r-j\}$. 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 $f=\max_l\{\sum_{i=1}^l o[i] \vert 1\le l \le j \}$. Return ef.

The following theorem summarizes the result of this section.


\begin{theorem}Given a clique $C$ , the node $e_f \in C$ computed by the algorithm above
has maximum unoriented degree among the nodes in $C$ .
\end{theorem}

The complexity of the algorithm is proportional to the size of C plus the number of unoriented nodes in $OV(\pi )$, and hence, it is O(n).


next up previous
Next: Algorithm Summary Up: An Algorithm for Sorting Previous: Finding a Happy Clique
Peer Itsik
2001-01-17