Title: Minimum enclosing circle problem
1Minimum enclosing circle problem
2Problem Given a set of n points in the plane,
find the circle of minimum radius that contains
all of the n points.
3Enclosing circle touching no point
Find a circle that contains all of points in its
interior
Starting from a sufficiently large circle, we
shrink the circle until it touches some point.
4An enclosing circle touching one point
Move the center toward the point on the circle
while touching the point
5An enclosing circle touching two points
Move the center along the perpendicular bisector
of the two points.
6Special case
A case in which the circle determined by the
diameter determined by two points is an enclosing
circle.
In this case, this circle is the
minimum enclosing circle.
7How many different enclosing circles?
A circle is defined by three points ? O(n3)
different circles
Hereafter, we only consider those circles passing
through three input points.
Are there so many circles?
If there are O(n3) different circles, a
triple-loop algorithm is reasonable to find the
minimum enclosing circle.
8Naive Algorithm
Algorithm Exhaustive-search P p1, p2, ... ,
pn D circle with infinite radius for i1 to
n-2 do for ji1 to n-1 do for kj1 to
n do Let D be the circle passing through
three points pi, pj, pk if radius(D) lt
radius(D) then check false
for h1 to n s.t. h ! i,j,k do
if ph lies outside the circle through pi, pj,
pk then check true
if check false (i.e., D is an enclosing
circle) then D D (update an
optimal solution) return D
9Lemma Let P be a set of points in the plane.
Fixed two points u and v in P. Then, there are
at most two enclosing circles that passes through
u, v, and another point of P.
10Conclusion There are O(n2) candidates for the
minimum enclosing circle since there are at most
two such candidates for each pair of points.
Algorithm Naive-2 P p1, p2, ... , pn D the
circle with the infinite radius for i1 to n-1
do for ji1 to n do if the circle Cij
with pipj being the diameter encloses all
the other points, then return it. D the
circle Cij for k1 to n do s.t. pk lies
outside Cij Let D be the circle passing
through pi, pj, pk if radius(D) lt
radius(D) then DD if D encloses all
points AND radius(D) lt radius(D) then
D D (update the current optimum) return D
O(n3)-time algorithm
11Then, is there any point set which has O(n2)
enclosing circles?
To answer this question, we need several
observations.
12Q1 Does the minimum enclosing circle always
passes through the point with the largest
y-coordinate?
NO
Q2 Does the minimum enclosing circle passes
through the two points that are farthest from
each other?
NO
Q3 When the minimum enclosing circle passes
through a point p, does it also pass through the
point q farthest from p?
NO
What is wrong?
13Q1 Does the minimum enclosing circle always
passes through the point with the largest
y-coordinate?
A point that is not maximal in any direction does
not contribute to the minimum enclosing circle.
Define a set of those maximal points.
red points are maximal in the directions specified
by arrows
14Any point in a triangle defined by three points
can be neglected.
v
p
w
u
Any circle passing through p cannot contain all
of u,v, and w. ? there is no enclosing circle
passing through p.
Prove that only maximal points can contribute to
the minimum enclosing circle.
15 A point with the largest y-coordinate is maximal.
Proof Let u be a point with the largest
y-coordinate. If u is not maximal, then there is
a triangle defined by three points of P that
contains the point u in its interior. But it is
impossible because the point u has the largest
y-coordinate.
Given a point set P, compute the convex hull and
remove all the points that are not maximal (not
on the convex hull).
Do all point pairs on the convex hull can
contribute to the minimum enclosing circle?
16p
The center of the circle for the three points is
the farthest point in the circle from the three
points.
c
r
q
How many such points that are equally distant and
farthest from three points? ? the number of
enclosing circles.
17Farthest-point Voronoi Diagram
point p in P V(p) the region in which p is
the farthest among P
V(4)
Point 3 is farthest in this region
V(3)
V(5)
1
of Voronoi vertices of enclosing circles
O(n) since the Voronoi diagram is a planar graph.
2
6
5
3
4
V(2)
V(6)
Prove the number of vertices of a Farthest-point
Voronoi diagram is O(n).
V(1)
18Algorithm based on Farthest-point Voronoi Diagram
Only the Voronoi vertices can be candidates for
the center of the minimum enclosing circle. No
need to check whether a circle encloses all
points. Just find the one minimizing the distance
to the farthest points (the distance is the
radius of the minimum enclosing circle). O(n)
vertices in a Farthest-point Voronoi diagram ?
the algorithm runs in O(n log n) time 1
construct a farthest-point Voronoi diagram O(n
log n) 2 find the vertex minimizing the
distance to the farthest points and
the minimum distance. O(n) In
total, O(n log n) time.
19Some useful observations.
Observation 1 If a triangle defined by three
points determining an enclosing circle is acute
(any internal angle is less than 90 degrees),
then it is the minimum enclosing circle.
Prove the observation.
20Observation 2 Pi p1, p2, ... , pi(a set
of the first i points) Di the minimum
enclosing circle for Pi Then, if pi is contained
in Di-1, Di Di-1. Otherwise, pi lies on the
boundary of Di.
The minimum-radius circle enclosing Pi-1 and
containing pi on the boundary
Algorithm MiniDisc(P) D2 the min.enclos. circle
for p1, p2 for i3 to n if pi is contained
in Di-1 then Di Di-1 else Di
MiniDiscWithPoint(Pi-1, pi) return Dn
pi
Di
21MiniDiscWithPoint(P, q) D1 min. enclos. circle
for q, p1 for j2 to P if pj is
contained in Dj-1 then Dj Dj-1
else Dj MiniDiscWith2Points(Pj-1, pj,
q) return Dn
q
pj
Dj-1
22D2disc(1,2) D3MDP(3,1,2) D1disc(3,1)
D2disc(3,1) 2 D3disc(3,1) D4MDP(4,1,2,3)
D1disc(4,1) D2disc(4,1) 2
D3disc(4,1) 2,3 D4disc(4,1) D5disc(4,1)
5 D6MDP(6,1,2,3,4,5)
7
6
8
1
5
2
4
3
237
D1disc(6,1) D2MDP2(6,2,1)
D0disc(6,2) D1disc(6,2) 1
D2disc(6,2) D3MDP2(6,3,1,2)
D0disc(6,3) D1disc(6,3)1
D2disc(6,3)1,2 D3disc(6,3)
D4MDP2(6,4,1,2,3) D0disc(6,4)
D1disc(6,4) 1 D2disc(6,4) 1,2
D3disc(6,4) 1,2,3 D4disc(6,4)
6
8
1
5
2
4
3
Give a similar example.
24Worst case analysis
Algorithm MiniDisc(P) time T(n) D2 the
minimum enclosing circle for p1, p2 for i3 to
n if pi is contained in Di-1 then Di
Di-1 else Di MiniDiscWithPoint(Pi-1,
pi) return Dn
MiniDiscWithPoint(P, q)time
T1(n) D1 the minimum enclosing circle for q,
p1 for j2 to P if pj is contained in
Dj-1 then Dj Dj-1 else Dj
MiniDiscWith2Points(Pj-1, pj, q) return Dn
25Worst case analysis
MiniDiscWith2Points(P, q1, q2) time
T2(n) D0 the minimum enclosing circle for q1,
q2 for k1 to P if pk is contained in
Dk-1 then Dk Dk-1 else Dk
disc(q1, q2, pk) return Dn
26Worst case analysis
computation time for MiniDisc(P)O(n3) worst
if Di is updated in each iteration
(invoking MiniDiscWithPoint(P, q)) Is there an
example that requires O(n3) time?
Just a small trick! Permute points randomly in
each iteration.
27Algorithm MiniDisc(P) Permute the point of P
randomly D2 the minimum enclosing circle for
p1, p2 for i3 to n if pi is contained in
Di-1 then Di Di-1 else Di
MiniDiscWithPoint(Pi-1, pi) return Dn
MiniDiscWithPoint(P, q) Permute the point of P
randomly D1 the minimum enclosing circle for
q, p1 for j2 to P if pj is contained in
Dj-1 then Dj Dj-1 else Dj
MiniDiscWith2Points(Pj-1, pj, q) return Dn
28MiniDiscWith2Points(P, q1, q2) Permute the point
of P randomly D0 the minimum enclosing circle
for q1, q2 for k1 to P if pk is
contained in Dk-1 then Dk Dk-1
else Dk disc(q1, q2, pk) return Dn
29Analysis of the computation time of MiniDisc
If the else part is never implemented then O(n)
time. Then, what is the probability that
MiniDiscWithPoint() is called? Using Backward
analysis Fix a subset p1, ... , pi . Let
Di be the circle enclosing p1, ... , pi and
passing thru q. When does the minimum enclosing
circle change? It happens only when we remove
one of three points on the boundary of Di .
Since q is one of the three points, the
probability that pi is one of those points is
2/i. Thus, the expected computation time is
That is, the expected computation time is O(n)!
30More detailed analysis
Worst case analysis T(n) 1 max(1,
T1(i)) T1(i) 1 max(1, T2(j))
T2(j) 1 max(1,1) j T2(j)j,
T1(i) 1i(i1)/2-1i(i1)/2 T(n)O(n3)
Analysis based on probability T(n) 1
1(1-3/i) T1(i)3/i T1(i) 1
1(1-2/j) T2(j)2/j T2(j) j T1(i) i
- 2 log i 2i 3i - 2 log i lt 3i T(n) lt n -
3 log n 3n O(n) Thus, T(n) O(n)