Theoretical
Computer Science
ELSEVIER
Theoretical
Computer
Science
175 (1997) 239-255
Planar stage graphs: Characterizations
and applications
Frank Bauerniippel a,c,3, Evangelos Kranakis a,‘9*, Danny Krizanc a,’ ,
Anil Maheshwari a,‘,2, JGrg-Riidiger Sack a,1, Jorge Urrutia b,’
aSchool of Computer Science, zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLK
Carleton University , Ottuwa, ON, Canada KIS 5B6
of Computer Science, University of Ottawa, Ottawa, ON, Canada KIS 5B6
c Institut ftir Informatik, Humboldt-Universitiit zu Berlin, 10099 Berlin, Germany
b Department
Abstract
We consider
combinatorial
and algorithmic
aspects
of the well-known
paradigm
“killing
two
We define a stage graph as follows: vertices are points from a planar
point set, and {u, u} is an edge if and only if the (infinite, straight) line segment joining u
to u intersects a given line segment, called a stage. We show that a graph is a stage graph
if and only if it is a permutation graph. The characterization results in a compact linear space
representation of stage graphs. This has been exploited for designing improved algorithms for
maximum matching in permutation graphs, two processor task scheduling for dependency graphs
known to be permutation graphs, and dominance-related
problems for planar point sets. We show
that a maximum matching in permutation graphs can be computed in Q (nlog* n) time, where
n is the number of vertices. We provide simple optimal sequential and parallel algorithms for
several dominance related problems for planar point sets.
birds
with
one
stone”.
1. Introduction
Suppose
a bounded
that an archer is hunting birds flying over hunting grounds described as
region possibly with holes formed by obstacles such as mountains, lakes,
dense forests, etc. In an attempt to minimize
tries to identify
the number
of arrows used, the archer
pairs of birds that can be pierced by a single arrow; this is possible,
if the positions of two birds line up with some point on the hunting grounds.
corresponds to the well known paradigm of “killing two birds with one stone”.
This
The planar archer problem can be modeled as follows: assume that X = { ~1,. . . , p,,}
is a collection of points in the plane (in general position) such that the y-coordinate
* Corresponding
author. E-mail:
[email protected].
’ Research supported in part by NSERC (Natural Sciences and Engineering Research Council of Canada)
grant.
2 Research supported in part under an R&D agreement between Carleton University and ALMERCO Inc.
3 Work by the author was carried during a stay at Carleton University.
0304-3975/97/$17.00
@ 1997-Elsevier
PZI SO304-3975(96)00201-O
Science B.V. All rights reserved
240
F. BauernGppel et al. I Theoretical Computer Science 175 (1997)
Fig. 1. Stage representation
of the graph
{2,5)> {2>6)> (2971,
(495).
{3,7},
239- 255
1, 2, 3, 4, 5, 6, 7 and edges { 1,4},
with vertices
{ 1,5},
of each element
of X is strictly greater than zero and let L be a line segment,
stage,
in the x-axis.
contained
Given X and L construct
a graph G(X,L)
{ 1,6},
called
with vertex
set X such that two vertices pi, pj of G(X,L) are adjacent if the line through pi and
pj intersects L. The graph G(X,L) will be called the stage graph of X and L (for an
illustration
see Fig. 1).
Applications
of stage graphs may arise in several problems
such as the positioning
of
floodlights to illuminate fixed objects in space and the positioning of directional satellite
antennae to pick up signals from ground stations, not to mention the traditional problem
of “killing
two birds with one stone”. An important
scheduling
and to dominance-related
1.1. Results
In Section
of the
problems
relationship
will be discussed
to two-processor
task
and exploited.
paper
2 we present
our characterization
theorem
for stage graphs. We prove
that the family of stage graphs is exactly the family of permutation
graphs. This yields
an efficient algorithm for recognizing such graphs. The characterization implies a compact linear space representation (encoding) for stage graphs. Also viewing permutation
graphs
as stage graphs allows
a geometric
interpretation
exploit this for the design of several algorithms including
archer’s problem and to dominance-related
problems.
of permutation
graphs. We
an efficient solution
to the
In Section 3 we study the archer’s problem. The problem of minimizing the number
of arrows the archer needs naturally corresponds to that of finding a maximum matching
in stage graphs. Therefore, it is possible to solve the problem, e.g., by using the Micali
and Vazirani matching algorithm [ 151. This results in an Q( fim)
algorithm where n
and m are the number of vertices and edges of the graph, respectively. A more efficient
algorithm is obtained when stating the problem as a two-processor task scheduling
problem. Efficient algorithms for finding tightest two-processor schedules are known
[3,7-91. We follow the approach of [3] that leads to an SZ(n+m) time algorithm for the
scheduling problem [ 191. Through vector dominance and using computational geometry
F: Bauerniippel et al. I Theoretical Computer Science I75 (1997) 239-255
241
techniques we establish that the problem has an Q(n log’ n) solution. We therefore not
only solve the archer’s problem efficiently, but also provide a novel and improved
algorithm
for matching
of a scheduling
improved
in permutation
problem
is known
two-processor
graphs. Furthermore,
to be a permutation
scheduling
algorithm
if the dependency
graph
graph, then we now have an
(if the number
of edges is Q(nlog2n)).
In Section 4 we present conceptually simple, new, and improved algorithms for vector dominance and rectangle query problems. Let zyxwvutsrqponmlkjihgfedcbaZYXWVUT
P = {pl, ~2,. . . , pn} be a planar
point set of n distinct
points
pi = (Xi, yi), i = 1,. . . , n. A point
pi is said to domi-
nate a point
pj, if Xi >xj and yi 2 yj and i # j. We present new, simple and optimal sequential and EREW PRAM algorithms for reporting all dominance pairs. Our
algorithms improve on the previous algorithm [lo] which requires the CREW PRAM
model of computation. A problem related to dominances is the rectangle query problem
for planar point sets P. A query consists of a pair of points (pi, pj), where pi, pj E P,
and we need to answer
whether
the rectangle
formed by the query points
is empty
or not. We design an Q(n log n) space data structure which answers rectangle queries
in Q( 1) time. The data structure can be constructed in sequential S2(n log n) time and
in Q(logn)
parallel
time using Q(n) EREW PRAM processors.
query algorithm improves
Q(log n) query) results.
Finally,
on previous
in Section 5 we conclude
2. Characterization
of single-stage
Our parallel rectangle
(Q(n2) space, Q( 1) query) or (Q(n log n) space,
with some open problems.
graphs
in the x-axis and let X = {PI,. . . , pn}
Let L be a stage, i.e., a line segment contained
be a planar set of points in general position with positive y-coordinates.
We give a
characterization
for the graph G(X,L) with vertex set X in which two vertices are
adjacent
if the line connecting
them intersects
L.
Let P(X, < ) be a poset. Then a realizer of P of size k + 1 is a collection
orders {L&K <s),Ll(X,
where the intersection
<I),.
. .,4(X,
of linear
such that
is defined by x < y H x <i y, for all i. It can easily be proved
that every poset can be obtained
Dushnik
<k)}
as the intersection
and Miller [6] define the dimension
of a number
of linear
orders.
of P to be the smallest possible
size of
a realizer of P. Partial orders of dimension 2 are known to be permutation graphs.
In the following theorem we will establish that stage graphs are permutation graphs.
This yields an Q(min{n2,n + m log n}) algorithm to recognize stage graphs with m
edges and n vertices.
Theorem 2.1. A graph G is a stage graph if and only if G is a permutation graph.
242
F. Bauerniippel
et al. I Theoretical
Computer
Science 175 (1997)
239-255
Proof. Consider a set X = {pi,. . . , pa} of n points in the plane with positive
y-coordinates
and a line segment zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLK
L contained in the x-axis, with end points p and
q. Let G(X, L) be the stage graph of X and L. We start first by proving
a comparability
graph, i.e., we show that it is possible
that G(X, L) is
to orient the edges of G(X,L)
such that if p, - - f pj and pj -+ pk then pi - - - f pk. To this end, let us assume
that
two vertices pi and pj of G(X,L) are adjacent, i.e., the line through pi and pj intersects L. We orient the edge {pi, pi} of G(X,L), pi + pj if the y-coordinate
of
pi is smaller
than that of pi,
the orientation
thus obtained
only if the triangle
contained
otherwise
in G(X,L)
d(pi, p,q)
in the triangle
defined
we orient
is transitive.
pj +
pi. We now prove that
Observe
that pj 3
by pi and the end points
pi if and
p and q of L, is
defined by pj and p and q. Thus, if pi +
A(pj, p,q)
pj
and Pj --t pk then A(pk,p,q)3A(pj,p,q)3
A(pi,p,q)
and thus pi -+ pk. This
orientation of G(X, L) defines a partial order P(X, <) on X in which pi < pj if zyxwvutsrqp
PI -+ Pi.
We now show that P(X, <) has dimension
ear extensions
2. To prove this we will produce two lin-
Ll(X, < 1) and L&Y, ~2) of P(X, < ) such that LI(X, < 1) fl Lz(X, < 2) =
P(X, < ). To produce
tion with respect
Ll(X, < 1) sort the points
to p, i.e., pi
smaller than the slope of the line joining
pi <2 pj if the slope of the line joining
direc-
pi to p is
pj to p. In L2(X, <2) we now define
pi to q is greater than the slope of the
pj to q (see Fig. 2, where Ll(X, < 1) = {pl < 1 p4 < 1 p3 < 1 ps < 1 pz}
line joining
and Lz(X, ~2)
=
{pi
~2 p3
Li(X, < 1) n Lz(X, <2).
=
of X in the counterclockwise
< 1 pj if the slope of the line joining
<2
Partial
p4
<2
orders
It now follows that P(X, <)
of dimension 2 are precisely permutation
p2
<I
ps}).
graphs.
Conversely,
let P(X, < ) be an ordered set of dimension
2 and L1 (X, < I ), L2(X, < 2)
be two total orders on X such that P(X, < ) = L,(X, < 1) rl L2(X, ~2). Choose two
points p,q on the x-axis as depicted in Fig. 3. Let pi be an element of X. Let r(i)
and s(i)
be the ranks
of pi in Ll(X, < 1) and L2(X, < 2), respectively.
. , A,,} of n lines
set {A,,.
through
p sorted
in increasing
Consider
order according
a
to their
slopes and a set {pi,. . . , &} of n lines through q sorted in decreasing order according to their slopes such that each Ai intersects each /?j at a point with positive
y-coordinate,
1 6 i, j <n.
sect and identify
{P2
p2
Let us label with pi the point at which Arci) and bs(i) inter-
the points
of X with ~1,. . . , pn (see Fig. 2, where Ll(X, <
1) = zyxwvutsrq
<I
PS> and L2(X
<>
=
(~3
~2
PI
~2
PS ~2
zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
<l
P4 zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
<l
P3
<l
Pl
<2
~4)).
~1,. . . , p,, and
It is now easy to see that the set X of points on the plane labeled
the line segment L are such that G(X, L) is the stage graph of
P(X, <).
0
Corollary
2.1. Stage graphs can be recognized in Sl(min{n2, n + m log n}) time.
Proof. Recognition of orders of dimension
R(min{n2,n + mlogn})
time [14, 17,201.
two (permutation
0
graphs)
can be done in
Computer
F. Bauerniippel et al. I Theoretical
Science 17.5 (1997)
243 zyxwvutsrq
239-255
P2
Fig. 2. The orders LI(X, <
1) and L2(X, ~2).
Fig. 3. The orders L1, L2
3. Matching/scheduling algorithms
In this section we provide an efficient solution to the archer’s problem. As mentioned
earlier, the problem of minimizing
the number of arrows that archer needs naturally
corresponds
to that of finding
cali and Vazirani
matching
and m are the number
a maximum
algorithm
of vertices
matching
in stage graphs. Using the Mi-
[ 151 an L?(J%)
solution
is obtained
and edges of the graph, respectively.
where it
A more effi-
cient solution is obtained by exploiting a relationship between matching and processor
scheduling discussed in Section 3.1. Our matching algorithm as presented in Section
3.2 is based on the characterization
theorem for stage graphs established above. Our
result implies
novel
two-processor
task scheduling
and improved
solutions
for permutation
to matching
in permutation
graph dependencies.
graphs
and
244
E Bauerniippel et al. I Theoretical Computer Science 175 (1997)
3.1.
239- 255
Relationship between matching and processor scheduling
As pointed out, e.g., in [16], there is an important
ings in co-comparability
graphs and the following
relation between maximum
scheduling
match-
problem.
Let G = (I’,,?) be a directed acyclic graph; let G have n vertices and m edges.
Vertex u E V is a sUccessoY of a vertex u E V if there is a directed path from u to
n in G. A two- processor scheduling for S is an assignment
the vertices
of time units
. to
1,2,3,.
u E V such that
1. each vertex v E V is assigned
exactly one time unit,
2. at most two elements are assigned the same time unit, and
3. if v is a successor of u in G, then u is assigned a smaller time unit than v.
The edges of G represent dependencies
among the set of n vertices (tasks) to be
executed. The largest time unit assigned to a vertex is called the length of the schedule.
Let us consider
a graph H = G*‘, the undirected
complement
of the transitive
closure of graph G. Two vertices u and v of H are adjacent if there is no directed
path from u to v or from v to u in G. Such a graph H is called a co- comparability
graph. It is known
of permutation
that the class of co-comparability
graphs properly contains the class
graphs [20].
The pairs of vertices scheduled
ing in H. On the other hand,
at the same time unit in G obviously
it has been
shown
form a match-
in [7] that for each matching
M
in H of size k a two-processor schedule for G of length n - k exists. As a consequence, a maximum matching in H corresponds to a tightest schedule in G and vice
versa.
Efficient
algorithms
follow the approach
for finding
a tightest
of [3, 191. This approach
two-processor
iteratively
schedule
are known.
assigns labels { 1,2,.
We
. , n} to
the vertices of the graph G. By L(u) we denote the label of vertex u and by N(u) we
denote the list (L(vi ),L(vz),
. . ,L(v,))
of the labels of the successors
of u in G. The labels in N(u) are sorted in decreasing order.
Suppose the labels 1,2,. . . , k - 1 have already been assigned.
with the value L(U) = k, if
Condition 1. All successors of u in G are already labeled.
Condition 2. For each other vertex U’ fulfilling Condition
lexicographically
not smaller than N(u).
Note that initially
all vertices
vi, i = 1,. . . , k,
A vertex u is labeled
1, the sorted list N(u’)
is
(Ties are broken arbitrarily.)
of outdegree
zero will be labeled,
Once the labeling is completed, all vertices are sorted by decreasing label and a
list schedule is constructed from that sorted list in a greedy manner: Each vertex is
scheduled at the smallest possible time unit. (Alternatively,
a greedy matching
on the sorted vertex list yields a maximum matching for H.)
It has been shown that the result is a tightest schedule [19]. Moreover,
algorithm can be carried out in 1V(G)1 + [E(G)1 time [19,9].
based
the entire
I? Bauerniippel et al. I Theoretical Computer Science 175 (1997)
Given a co-comparability
graph H, we can compute
245
239- 255
a maximum
matching
in fi(n2)
time using the above algorithm. Since stage graphs can be represented more compactly,
i.e., in Q(n) space, we are interested in a faster algorithm for this class of graphs.
3.2. E#cient
matching and processor scheduling
We use the stage characterization
scheduling
Observe
theorem
to obtain
algorithms in a permutation graph.
that the complement of a permutation
Hence, the problem
a permutation
reduces
graph.
to that of finding
Using
the geometric
show that simple geometric
ing algorithm
arguments
more efficient
graph is also a permutation
an optimal
interpretation
and data structures
whose run time is (possibly)
matching
sublinear
and
graph.
two-processor
schedule
of
of permutation
graphs
we
suffice to design a match-
in the number
of edges of the
graph.
To achieve this, partition the vertices into leuels. The level of a vertex u E V, denoted
as L(v), is the length of the longest path from u to a vertex of outdegree zero. It is
holds: If vertex u E V is at a higher level than vertex
easy to see that the following
li E V, then L(u) > L(v). This can be shown by an inductive argument. The vertex v
has at least one successor at level L(u) - 1 >L(u) whereas u has no successor at this
level.
This partitioning
resentation
into levels corresponds
of a permutation
time. The challenge
are labeled without
graph. The partition
is to determine
looking
to vertex domination
in the geometric
into levels can be done in C&n log n)
the order in which the vertices
at all incidences.
rep-
Instead
of determining
within
a level
sorted lists N(V)
we use a geometric argument. Denote by DomReg(p)
the upper right quadrant of an
axis-aligned coordinate system whose origin is at point p. In this section, a point p
dominates
Max(R)
a point q if q lies in DomReg(p).
denotes
the maximum
zero if R contains
Let R be any region of the plane; then
label of all labeled
points which lie in R, it is set to
no labeled point.
Now let u and v be two points on a common
generality, that u lies above v, i.e., u’s y-coordinate
level and assume, without loss of
is larger than v’s. The intersection
of DomReg(u) and DomReg(u) is a quadrant called SharedQ(u,v).
DomReg(u) can be partitioned into SharedQ(u, u) and the remaining
gle, called Ret(u);
only if Max(Rec(u))
similarly,
Then the region
half-open rectan-
for v (see Fig. 4). Now, observe that L(u) > L(v) if and
is greater than Max(Rec(v)).
This reduces the problem of performing a comparison operation of the form “L(u) >
L(v)” (as needed for sorting each layer) to a comparison
between two integers
(labels)
obtained via Maximum-Labeled-Element-Queries
in half-open
rectangles.
There
are different approaches to solving such queries: one is to state the problem as a
(dynamic) 3-D range searching problem where the third coordinate is the label, the
other, taken here, is to use the range priority search trees (called range trees, see e.g.
[IS]). A range tree stores the points sorted by x-coordinate in its leaves. Located at
each internal node is a y-sorted list of all points in its subtree.
246
F. Bauerniippel et al. I Theoretical Computer Science I75 (1997)
I
239- 255
zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCB
I
: Ret(u)
zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONML
0
I 0
I
I
.’
I
SharedQ(u,v)
0
I
I
0
0
I
I
0
u&---I_-__---____
0
I
l
Ret(v)
zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLK
l
0
0
I
vi___-o-______
0
0
Level I
0
Level 2
l
Level 3
Fig. 4. The regions
0
Ret(u),
Ret(v)
To perform a Maximum-Labeled-Element-Query
find the maximum
and [xb, +co].
structure
numbers
and SharedQ(u,
in a half-open
labeled point in R, where R is bounded
To answer
these queries
0).
rectangle zyxwvutsrqponmlkjihgf
R, we must
by [x,, ya], [xb, ya], [x0, +oo]
we build two data structures.
The first data
is a range tree that reports the maximum layer number 1 among all layer
corresponding
to each point in R. Given I and R, the second data structure
reports the maximum labeled point in the layer 1, among all points of I lying inside R.
The (priority) range tree is computed as follows. Sort the points in increasing
x-coordinate.
Build a balanced
binary
search tree T over them. At each internal
node
u sort the points, which are in the subtree rooted at u, by their y-coordinates
and
determine the maximum label among all points in the subtree. For each point pi at
node u of T, compute the maximum layer number among all points at u which have
higher y-coordinate
with respect to pi. Also assume that there are cross-ranking
point-
ers associated between a node and its parent and between a node and its sibling. It
can be seen that the preprocessing takes s2(n log n) time and S2(n logn) space using
the algorithm of [4].
F. Bauerniippel et al. I Theoretical Computer Science I75 (1997)
The queries
subtrees
in the first tree are answered
spanning
the x-range
as follows.
239- 255
247
We locate Q(logn)
roots of
[x,,xb] and for each of these we use the sorted y-lists
to compute the maximum layer number in its y-range. The maximum layer number
is the maximum of at most Q(logn) values computed in the above step. Note that in
each of these lists we do not have to perform a binary
using the cross-ranking
information.
in L?(logn) time.
The second data structure
is computed
any layer I is x - y monotone.
the points
search since we can locate y,
Thus, the queries in the first tree can be answered
Hence,
for every layer of the point set. Observe that
I can be represented
in A(Z) follow the respective
order. Given
by an array A(Z), where
the half-open
rectangle
R, the
points of 1 in R can be located by performing a binary search in A(Z) by choosing the
appropriate x and y coordinates as the keys. Note that the points of I in R forms an
interval
in A(Z). So the problem
reduces to that of computing
of computing
the maximum
the maximum
element
labeled point in R of I
of an interval
in A(I).
We know
that an array containing integers in the range 1,. . . , n can be preprocessed in Q(n) time
and the maximum interval queries can be reported in Q( 1) time [ 111. Thus, the second
data structure
be answered
can be computed
in Q(logn)
in Q(n) time using 0(n)
time. Now we describe
storage and the queries can
our algorithm.
Algorithm for maximum matching
1. Compute
graph.
2. Partition
its
the
the
layer
vector
point
dominance
set
into
representation
layers,
of the
and
1,2,...,k
assign
range
where
l,...,nl,
nl
is the
number
layer. All other points are initialized
to
the second data structure for the points
5. For
layers
sort the
each
point
layer
from
number.
3. Build the first data structure - the range tree.
4. Assign arbitrarily
the labels to the points in the
the
permutation
i=2,3
points
,..., k
on
first
of points
on the
0 as their labels.
in the first layer.
first
Build
do
layer
i (using
the
above
described
comparison
operator)
and assign consecutive
labels to the points.
6. Perform a greedy matching
on the labeled graph.
Note that the labels for layer
i
are computed
using (only)
i- 1; the location of each point remains unchanged.
Q(log n), since the queries in both data structures
the labels of layers 1 to
The total time per point is therefore
can be answered in Q(log n) time.
The second data structure is built in linear time, once we assign labels to each point on
that layer. If an optimal sorting algorithm is used, the total number of queries can be
bounded by ~~._l ni log ni, where ni denotes the cardinality of layer i. Thus, all labels
can be assigned in Q(n log2 n) time. Now we show how the greedy matching can be
performed.
248
E Bauekippel
The matching
et al. I Theoretical Computer Science I75 (1997)
can be done by a sequence
of a(n)
239- 255
Maximum-Labeled-Element-
Queries using the quadrant DomReg(p)
for finding point q to be matched with p.
It examines points in decreasing order of their labels and tries to match them. Once p
and q are matched, both of them are deleted from the point set. To compute the matching, a dynamic
range-range
priority search tree is used. Sort the points by x-coordinate
and arrange them in a binary
search tree (i.e., the primary
tree). At each node of the
tree, sort all points in its subtree by y-coordinate and build a binary search tree over
them (i.e., the secondary tree). This data structure can be built in !2(nlogn)
time and
S2(n logn)
space using the algorithm
query is performed
spanning
as follows.
the x-range
to compute
of [4]. Given
Locate R(logn)
of DomReg(p)
a point
p, the maximum-labeled
in the primary
tree
and for each of these we use the secondary
tree
s2(log n) roots of subtrees
spanning
roots of subtrees
the y-range
of DomReg(p).
So, in
all we have CJ(log* n) values, and the maximum labeled point q is the maximum of
these values. Thus, the maximum point q can be reported in !2(log* n) time. The next
step is to remove the point q from the data structure. Locate the leaf of the primary
tree containing the point q. Now walk up this tree to its root and at each intermediate node, update the secondary
Since there are only S2(logn)
tion of q from the data structure
be computed
tree starting
secondary
from the leaf containing
trees to be updated,
is sZ(log* n) time. Hence,
q to its root.
the total time for delethe greedy matching
in s2(n log’ n) time. The above results are summarized
can
in the following
theorem.
Theorem 3.1. M aximum matching in a permutation graph G can be computed in
Q(n log* n) time where n is the number of vertices of G.
Corollary
3.1. The problem of minimizing the total number of arrows to kill all
n birds can be solved in Q(n log* n) time.
Since complement
following
graphs of permutation
graphs are permutation
graphs we get the
result.
Theorem 3.2.
The two- processor task scheduling for dependency
graphs known to
be permutation graphs can be solved in Q(n log* n) time where n is the number of
processes
(not dependencies).
4. Dominance
4.1.
problems
M otivation and related results
Dominance
problems
arise naturally
in a variety of applications
and they are directly
related to well-studied geometric and non-geometric problems. These problems include:
range searching, finding maximal elements and minimal layers, computing a largest area
empty rectangle in a point set, determining the longest common sequence between two
F Bauerniippel et al. I Theoretical Computer Science 175 (1997)
strings, and interval/rectangle
also required
i =
for our matching
intersection
problems,
249
239- 255
etc. Dominance
computations
were
algorithm.
Let P = {P~,PZ,. . ., pn} be a planar point set of n distinct points pi = (xi,,)+),
l,..., n. A point pi is said to dominate a point pi, if xi axj and yi >yj and i # j.
Preparata
and Shamos
reporting
the dominances
[ 181 presented
optimal
sequential
algorithms
for each point of the set P. Their algorithm
for counting
and
runs in Q(n log n)
and SZ(n logn + k) time, respectively, where k is the total number of dominance pairs.
In the reporting mode of the problem, all dominance pairs are to be enumerated.
Goodrich [lo] solved this problem in Q(logn) time using Q(n+k/log n) CREW PRAM
processors, where k is the total number of dominance pairs. The two-set dominance
counting
was solved by Atallah et al. [l] in optimal Q(logn)
problem
processors,
where n is the total number
time using Q(n)
of points in the given sets. In this problem,
given two point sets A and B, all pairs (a,b) are to be counted where a E A dominates
b E B. In the reporting
Goodrich
mode of the problem,
all dominance
pairs are to be enumerated.
[lo] solved this problem in Q(log n) time using L&n/ log n+k) CREW PRAM
processors, where k is the total number of dominance
problems have been studied for the CREW-PRAM.
A problem
related to dominances
pairs. In [5] direct dominance
is the rectangle query problem for planar point
sets P. A query consists of a pair of points (pi, pj), where pi, pj E P, and we need
to answer whether the rectangle formed by the query points is empty or not. Such
rectangle
queries
find application
easily be answered
structures
e.g. in databases.
Given
L?(n2) space, queries
can
in Q( 1) time. The space can be reduced to L?(n log n) using data
that support range searching
[ 181, unfortunately
the query time increases
to
Q(log n).
4.2. Our results
We present a simple optimal parallel algorithm for reporting all dominances in a planar n-point set; it runs in Q(log n) time using S2(n + k/log n) EREW PRAM processors.
For the rectangle
query problem,
we provide
an Q(n logn)
size data structure,
where
the queries can still be answered in Q( 1) time. Furthermore, the data structure is very
simple and can be computed in sequential Q(n log n) time and in parallel L?(log n) time
using Q(n) EREW PRAM processors,
of computation,
respectively.
For details on the parallel
model
see e.g. [12, 111.
Our methods for solving both problems is different from the existing methods;
reduce the problems to one-dimensional
problems. This is achieved by ordering
points with respect to x-coordinate and then redefining
the corresponding permutation on y-axis.
these problems
we
the
with respect to
4.3. Algorithms for reporting dominances
In this subsection, we provide algorithms for reporting dominances of a planar point
set P. Without loss of generality, assume that the points of the set P = { ~1, ~2,. . . , p,,},
where pi = (xi, yi), i = 1, . . . , n, are sorted with respect to increasing x-coordinate.
250
Therefore,
F. BauernSppel et al. I Theoretical Computer Science 175 (1997)
we relabel
pi by its index i and from now on, we refer to a
each point
point pi by its index i. Let Y be the array consisting
respect to increasing
239- 255
y-coordinate,
of labels of points in P, sorted with
i.e., Y is a permutation
of { 1, . . . , n}. Let i appear
at the position pas(i), where 1 <pas(i) <n, in Y. From the above definitions it follows
that a point i dominates a point j E P if and only if i > j and pas(i) > pas(j). Hence,
the points dominated
by i are the elements
less than i. So the dominance
subarray
Y[ 1,. . . , pas(i)]
reduces to that of reporting
which are
all elements
of the
i - l] which are less than Y[i], for all i E (2,. . . , n}.
Y[l,...,
We provide
problem
of the subarray
first a sequential
algorithm
for the above problem
and then show that
it can be easily parallelized.
The sequential algorithm is based on the merge sort
algorithm; it runs in S2(n log n + k) time using linear space, where k is the total number
of dominance
in the given point set P.
relations
The sequential
algorithm
has Q(logn)
merge stages. In order to simplify
notation,
we present the last merge stage. Assume that we know all dominances for each point
within subarrays Y[ 1,. . . , n/2] and Y[n/2 + 1,. . . , n]. We wish to compute dominances
for each point in Y[ 1,. . . , n]. Observe
that we need to only compute
inated by Y[n/2 + l,...,
n/2], since no point in Y[ 1,. . , n/2] dominates
n] in Y[l,...,
any point in Y[n/2 + 1,. . . , n]. The dominances
that the arrays
creasing
Y[ 1,. . . , n/2]
order during
are computed
as follows.
Y[n/2 + 1,. . . , n] have already
and
the recursion.
Now rank each element
the points dom-
been
First note
sorted
in in-
of Y[n/2 + 1,. . . , n] in
Y[l,..., n/2]. Suppose an element Y[i], where n/2 + 1 <i Gn, is ranked at the position j (ldj<n/2)
in Y[l,..., n/2], the points dominated by Y[i] in Y[ 1,. . . , n/2] are
Y[j]. After cross-ranking,
we can report dominances in time proporJvl, zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
WI,...,
tional to the number
of dominance
pairs. We summarize
the result in the following
theorem. zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
Theorem 4.1. All dominances of an n-point planar set can be computed in Q(n logn+
k) time using Q(n) space, where k is the total number of dominance pairs.
Proof. The correctness
of the algorithm
plexity. The merge-sort
algorithm
is straightforward.
Now we analyze
its com-
takes Q(n log n) time using Q(n) space. During each
stage in merging, the ranking of the subarrays can be performed in linear time with
respect to their sizes. Since in each stage we report a set of new dominance pairs, the
overall time complexity
of merge-sort,
linear space.
of the algorithm
follows. In order to perform the (i+ 1)th stage
we need only the result of the ith stage; thus the algorithm
0
requires only
Now we parallelize the above algorithm using the results of [4, 131. The parallelmerge sort algorithm of [4] cross-ranks elements of each subarray during each stage
of merging. As observed above, after cross-ranking,
the problem reduces to that of
reporting subarrays Y [ 1,. . . ,j] for an appropriate j, where 1 <j&n/2, for each Y[i],
where n/2 + zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
1 < i <n. Subarrays can be optimally reported on an EREW PRAM by the
algorithm of [ 131. We summarize the result in the following theorem.
E Bauernippel
et al. I Theoretical Computer Science 175 (1997)
2.51
239- 255
Theorem 4.2. All dominances of an n- point planar set can be computed in Q(logn)
time using G!(n+k/log n) processors on the EREW PRAM, where k is the total number
of dominances.
Proof. The correctness
of the algorithm.
of the algorithm
Parallel
is straightforward.
merge sort requires
We analyze the complexity
SZ(logn) time using
Q(n) processors
on
the EREW PRAM [4]. Further, it also cross-ranks subarrays in each step. Using this
information, the value of k can be computed in SZ(logn) time using Q(n) processors.
Allocate
Q(n + k/logn)
the sorted subarrays
processors
to report all dominances.
at each intermediate
We also need to store
stage in merge-sort.
Using the algorithm
of
[13], the required subarrays can be reported in Q(logn) time using Q(n + k/logn)
processors [13]. Hence, it follows that all dominances can be reported in Q(logn) time
fl
using G’(n + k/logn) EREW PRAM processors.
4.4. Algorithms for the rectangle query problem
In this subsection
we address the rectangle
query problem.
Given an n-point
planar
set P, the queries are of the form (pi, pj), where pi, pj E P, and we need to output,
whether or not the rectangle formed by pi and pj contains a point of P in its interior. We provide
structure,
sequential
and parallel algorithms
such that the queries can be answered
to compute
an Q(n log n) size data
in sZ( 1) time.
subsection, we assume that the points of the set P = { pl, ~2,. . ,
p,},
where pi = (xi,y i), i = 1, . . . , n, are sorted with respect to increasing x-coordinate.
Therefore, we relabel each point pi by its index i. We refer to a point pi by its index
As in the previous
i. Notice
that our queries
assume that i < j, otherwise
are of type (i, j),
where
we interchange
i and j.
We compute two data structures,
the other one answers
the queries
1 6 i, j dn.
Furthermore,
we can
the first one answers the queries where yi <yj,
where yi > yj. Since the procedure
and
for computing
both data structures and answering the corresponding
queries is analogous, we only
discuss the computation of data structure which handles the queries where yi 6 yj.
Let Y be the array corresponding
to the labels of points in P sorted in increasing
y-coordinate.
Let (i, j) be a query pair, where i < j and yi d yj. Let i appear at the
position pas(i) in Y, where 1 <pos(i)dn.
The following lemma enables us to reduce
our problem
problem
of detecting
whether
a rectangle
is empty or not to a one-dimensional
on Y.
Lemma 4.1. The rectangle formed by (pi, p,) is empty tf and only if there does not
exist any element Y[k], such that i < Y[k] ,< j, where pas(i) < k < pas(j).
Proof. Follows
from the definition
In the following,
of the array Y.
we first state a sequential
which can answer the existence
of Y[k] between
0
algorithm
to compute
(pos(i),pos(j))
a data structure,
as stated in the above
zyxwvutsrqp
252
F Bauerniippel et al. I Theoretical Computer Science I75 (1997)
lemma,
and then we show how queries
algorithm
for computing
can be answered.
the data structure
Before stating our algorithm,
239- 255
Further,
we show that the
can be easily parallelized.
we simplify notation
by restating the problem.
Our aim
is to preprocess the array Y (assume n = 2’) such that, given any two indices a and b,
where 1 da < b dn, we can determine whether there exist an element in the subarray
{Y[a+ ll,..., Y[b - l]}, which is between Y[a] and Y[b] in O(1) sequential time. Intuitively, it seems that we need to precompute this information for some subarrays, and
then given a query array, the relevant
number
binary
of precomputed
subarrays.
tree T on the elements
information
We achieve
should be deduced
from a constant
our goal by constructing
of Y such that each internal
a complete
node u of T keeps some
information about the array determined by the leaves in the subtree rooted at U. In the
following, we precisely state the information maintained at each internal node u of T.
Let LCA(a, 6) denote the lowest common
ancestor node of the leaves of T holding
Y[a] and Y[b]. Given two indices a and b, we can determine LCA(a,b), say the node
U, of T in Q(l) sequential time since T is a complete binary tree. If the leaves of the
subtree rooted at u correspond
cient to store an information
exactly to the subarray
{ Y[a], . . . , Y[b]}, then it is suffi-
at u, about the presence or absence of an element between
Y[a] and Y[b] in the subarray
{ Y[a+ 11,. . . , Y[b-
11). However, the subarray associated
with U, denoted by Y,, is typically of the form of { Y[Z], . . . , Y[a], . . . , Y[b], . . , Y[r]},
where I <a < b <r. Hence, the information stored at the node u is not sufficient to
answer our query, and some additional
information
is needed,
Let u and w be the left and right child of u, respectively.
sociated
{Yip +
partition
with v and w, respectively,
as described
next.
Let the subarrays
be Y, = { Y[1], . . . , Y[a], . . . , Y[p]}
as-
and Y, =
11,.. . , WI,. . . , Y[r]}
for some a d p < b. Notice that the subarrays Y, and Y,
Y,,. Let us define two quantities, called @ fix- minimum and prejix- maximum,
respectively,
over the elements
of arrays Y, and Y,.
For any c(, where 1 da Q p, the suffix-minimum
for cc in Y, is defined as follows.
Among the elements of the subarray {Y[ol + 11,. . . , Y[p]} consider only the set of
elements
minimum
larger than Y[cr], and call this set Suff(or). If Suff(a)
for CI is the element
with the minimum
# 0, then the suffix-
value in Suff(a),
otherwise
suffix-
minimum does not exist for a. Similarly we define prefix-maximum.
For any fl, where
p+l </I fr, the prefix-maximum
for fl in Y, is defined as follows. Among the elements
of the subarray {Y[p+
l],...,Y[j?l]}, consider only the set of elements which are
smaller than Y[j?], and call this set Pref(j3). If Pref(@ # 0, then the prefix-maximum
for /I is the element with the maximum value in Pref(/?), otherwise it does not exist
for /I.
Let us first analyze
the complexity
of constructing
the whole data structure.
The
algorithm constructs a complete binary tree whose leaves are the elements of Y such
that each internal node u has associated with it two arrays, suffix-minimum
and prefixmaximum arrays. It can be seen that the data structure occupies SZ(n log n) space. Now
we show that the data structure can be computed in 52(n log n) time.
We make two copies of array Y, and on one copy we perform a merge-sort algorithm. The merge-sort algorithm, computes a complete binary tree T’, over Y, and at
F Bauerniippel et al. I Theoretical Computer Science 175 (1997)
253
239- 255
each internal node u of T’ it computes a sorted list of elements in the subtree rooted
at U. Furthermore, we cross-rank the elements of the left and the right child of u in
T’. Also store the sorted list, and the cross-ranking
information,
of T’. It is easy to see that this can be accomplished
at each internal
in SZ(n logn)
node
time and space.
Now we work on the other copy of Y to compute the suffix-minimum
and prefixmaximum arrays. Consider a node u of T, and let u and w be its left and right child,
respectively.
Assume
that we know the suffix-minimum
and prefix-maximum
arrays
for v and w and we wish to compute these arrays for the node u. Notice that the
suffix-minimum
and prefix-maximum
for each element in u can be computed by using the cross-ranking
information
among
the elements
of u and w in the merge-sort
tree T’.
It is easy to see that the above data structure can be computed in Q(n log n) sequential
time and in parallel in s2(log n) time using Q(n) EREW PRAM processors
by using the
parallel merge-sort algorithm of [4]. Now we show that the queries can be answered
in 52( 1) time. The following lemma is crucial to establish the correctness and the
complexity. zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
Lemma 4.2. Let u be the lowest common ancestor node corresponding to a and b in
T, where a < b. Let v and w be the left and right child of u, respectively . Let the
subarray s associated with v and w be
Y, =
{Y[4.. , Ual,. . . , Y[pl)
and
Y, = {Y[p
+ l] ,...,
Y[b],. .., Y[r]},
where a< p < b, respectively . There exists an element between Y[a] and Y[b] in the
subarray {Y[a+
l],...,
Y [b - I]} if and only if either the &fix- minimum
Y, is smaller than Y[b], if it exists, or the pre$x- maximum
of Y [a] in
of Y[b] in Y, is larger
than Y[a], if it exists.
Proof. Follows
Let us recall
to x-coordinate
from the definition
our problem.
and labeled
of suffix-minimum
We are given
accordingly.
and prefix-maximum.
a set P of points,
0
sorted with respect
Our queries are of the form (pi, pj), where
pi, pj E P. We want to report whether the rectangle formed by pi and pj is empty
or not. We first test whether i < j, if not, we interchange i, j. We compute two data
structures,
one to handle
the queries
where yi <yj
queries where y; > yj. Let us concentrate
and the other one to handle
the
on the queries of the first type. We defined
the array Y, which was the order of the indices of points of P with respect to increasing
y-coordinate. We compute a data structure over Y, i.e., a complete binary tree T, where
nodes of T also contain appropriate
suffix-minimum
and prefix-maximum
arrays. Given
a rectangle query (pi, pi), where i < j and yi < yj, we find the position a = pas(i)
and b = pos( j) in Y of i and j, respectively. Now determine the lowest common
ancestor node of a and b, say U, in T. Locate the position of Y[a] and Y[b] among the
children of u in T and then using the suffix-minimum
and prefix-maximum
informations computed in T, answer the query. Since finding the lowest common ancestor in a
254
F Bauernoppel
et al. I Theoretical
Computer
complete binary tree and locating the appropriate
the queries can be answered
theorem.
Science I75 (1997) 239-255
Y[a] and Y[b] requires constant time,
in L?(1) time. We summarize
the results in the following
Theorem 4.3. zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA
A data structure of size Q(n logn)
can be computed in Q(nlogn)
sequential time and in SZ(logn) parallel time using Q(n) EREW
PRAM processors,
so that the rectangle queries can be answered in Q( 1) sequential time.
5. Conclusion
We have introduced
interesting
the archer’s
problem
and shown that its solution
class of stage graphs which we characterized
to be permutation
leads to the
graphs. The
characterization
which leads to the solution for the archer’s problem allowed for the
development of improved algorithms for matching in permutation graphs, for a class
of two-processor
scheduling
There are several interesting
problems,
and for several geometric
open problems
upper bound on the matching be improved?
algorithm be reduced to linear?
problems.
suggested by our investigations.
Can the
Can the space required by the dominance
References
[l] M.J. Atallah, R. Cole and M.T. Goodrich, Cascading divide-and-conquer:
a technique for designing
parallel algorithms, SIAM J. Comput. 18 (1989) 499-532.
[2] B. Bollobas, Extremal Graph Theory (Academic Press, New York, 1978).
[3] E.G. Coffman and R.L. Graham, Optimal scheduling for two-processor
systems, Acta Inform. 1 (1972)
200-213.
[4] R. Cole, Parallel merge sort, SIAM J. Comput. 17 (1988) 770-785.
[S] A. Datta, A. Maheshwari and J.-R. Sack, Optimal parallel algorithms for direct dominance problems,
in: Nordic Journal of Computing 3 (1996) 72-88.
[6] B. Dushnik and E. Miller, Partially ordered sets, Amer. Math. Monthly 55 (1948) 26-28.
[7] M. Fujii, T. Kasami and K. Ninomiya, Optimal sequencing of two equivalent processors,
SIAM
J. Appl. Math. 17 (1969) 784-789.
[S] H.N. Gabow, An almost-linear algorithm for two-processor
scheduling, J. ACM 29 (1982) 766-780.
[9] H.N. Gabow and R.E. Tarjan, A linear-time algorithm for a special case of disjoint set union,
J. Comput. System Sci. 30 (1985) 209-221.
[lo] M.T. Goodrich, Intersecting line segments in parallel with an output-sensitive
number of processors,
SIAM J. Comput. 20 (1991) 737-755.
[ll] J. JaJa, An Introduction to Parallel Algorithms (Addison-Weseley,
Reading, MA, 1992).
[ 121 R.M. Karp and R. Vijaya Ramachandran,
Parallel algorithms for shared-memory
machines, in: J. van
Leeuwen, ed., Handbook of Theoretical Computer Science, Vol. 1 (Elsevier, Amsterdam, 1990).
[13] A. Lingas and A. Maheshwari, Simple optimal parallel algorithm for reporting paths in trees, in: Proc.
Symp. on Theoretical Aspects of Computer Science, Lecture Notes in Computer Science (Springer,
Berlin, 1994).
[14] R.M. McConnell and J.P. Spinrad, Linear-time modular decomposition and efficient transitive orientation
of comparability
graphs, in: Proc. ACM-SIAM
Symp. on Discrete Algorithms (1994) 536-545.
[15] S. Micali and V.V. Vazirani, An Q(fiIZ)
algorithm for finding maximum matching in general graphs,
in: Proc. 2lst Ann. IEEE Symp. Foundations of Computer Science (1980) 17-27.
I! Bauerniippel
et al. I Theoretical
Computer
Science 175 (1997) 239-255
255
[16] A. Moitra and R.C. Johnson, A parallel algorithm for maximum matching on interval graphs, in: Proc.
18th Internat. Conf on Parallel Processing III (1989) 114-120.
[ 171 A. Pnueli, S. Even and A. Lempel, Transitive orientation of graphs and identification of permutation
graphs, Canad. J. Math. 23 (1971) 160-175.
[1X] F.P. Preparata and M.I. Shamos, Computational
Geometry: An Introduction (Springer, New York,
1985).
[19] R. Sehti, Scheduling graphs on two processors, SIAM J. Comput. 5 (1976) 73-82.
[20] J. Spinrad, On comparability and permutation graphs, SIAM J. Comput. 14 (1985) 658-670.