d1 + d2 < d3

SOFSEM 2007
Weighted Nearest Neighbor Algorithms for
the Graph Exploration Problem on Cycles
Eiji Miyano
Kyushu Institute of Technology, Japan
Joint work with
Yuichi Asahiro, Shuichi Miyazaki, and Takuro Yoshimuta
1
Overview
 Problems
 Related problem: Traveling Salesperson Problem (TSP)
 Our problem: Online Graph Exploration Problem
 Simple online algorithms and their performances
 Our algorithm: Weighted nearest neighbor algorithm
 Main results
 1.5 competitive algorithm for special graphs, ie., cycles
 1.5 tight example
 1.25 lower bound for deterministic online algorithms
 Conclusions
2
One of the most popular problems
Traveling Salesperson Problem, TSP
(more precisely, the shortest tour problem)
Input:
 We in advance have the complete
map of an input graph, i.e.,
8
 the origin node o,
 the number of nodes,
 the number of edges,
 the length of every edge, and
 the topology.
Goal:
 Minimize the total distance of the traveled
tour, beginning at the origin o, visiting all
the nodes at least once, and finally returning
to the origin o.
origin
3
5
5
4
3
3
7
2
1
3
4
3
One of the most popular problems
Traveling Salesperson Problem, TSP
(more precisely, the shortest tour problem)
Input:
 We in advance have the complete
map of an input graph, i.e.,
8
 the origin node o,
 the number of nodes,
 the number of edges,
 the length of every edge,
 the topology.
Goal:
 Minimize the total distance of the traveled
tour, beginning at the origin o, visiting all
the nodes at least once, and finally returning
to the origin o.
origin
3
5
5
4
3
3
7
2
1
4
3
3
Total distance = 36
4
Our problem
Online Graph Exploration Problem
Initial Information:
 Only the partial information of
the map is given, i.e.,
the searcher knows only
searcher
3
origin
5
u
 the origin o
 its neighbor nodes
 the length of edge (o, u) for
each neighbor node u
???
 By using the partial information,
the searcher has to select the next node
and visit it.
5
Our problem
Online Graph Exploration Problem
Initial Information:
 Only the partial information of
the map is given
 the origin o
 its neighbor nodes
 the length of edge (o, u) for
each neighbor node u
3
u
origin
5
4
8
Online New Information:
 When the searcher visits a node u,
its neighbor nodes v’s, and the length
of edges (u, v)’s are obtained.
???
6
Our problem
Online Graph Exploration Problem
Initial Information:
 Only the partial information of
map is given
 the origin o
 its neighbor nodes
 the length of edge (o, u) for
each neighbor node u
Online Information:
 When the searcher visits a node u,
its neighbor nodes v’s, and the length
of edges (u, v)’s are obtained.
5
3
5
4
8
3
Goal:
3
7
???
 Minimize the total distance of the traveled tour,
beginning at the origin o, visiting all the nodes
at least once, and returning to the origin o.
7
Quality of an online algorithm
Competitive analysis
 Let OPT(G) denote the total length of the shortest exploring tour of G
taken by an optimal offline algorithm OPT.
 Let ALG(G) denote the total length of the exploring tour of G taken by
algorithm ALG.
We say that ALG is -competitive for a class of graphs G if
ALG (G) OPT(G)  
for all graphs G  G.
 The ratio  is called the competitive ratio.
 ALG is competitive if ALG is c-competitive for some constant c.
8
Strategy 1:
Nearest Neighbor Algorithm (NN)
 always chooses the unvisited new node nearest to the
current position.
10
1
origin
a
2
4
2
8
1
a
b
3
origin
b
 NN is Bad [RSL97]
 There is a planar graph G (with n nodes) for which
NN (G )
 (log n)
OPT (G )
9
NN is bad
 There is a planar graph G for which
2
[RSL97]
origin
NN (G )
 (log n)
OPT (G )
1
OPT(G) = 32
NN(G) = 66
2
2
1
1
1
2
3
3
10
3
6
1
2
1
1
3
6
2
2
2
1
Generally,
OPT(G) = n
NN(G) = (nlog n)
10
Strategy 2:
Depth-First algorithm (DF)
 Basically, if the current node has new edges, then
DF always chooses one of them.
 Otherwise, DF chooses the nearest new edge.
Proposition 1
DF is 1-competitive (optimal) for trees, i.e., graphs without loops.
origin
2
d
o
1
a
7
b
8
c
11
DF is bad
 Basically, if the current node has new edges, then
DF always chooses one of them.
 Otherwise, DF chooses the nearest new edge.
Proposition 1’
DF is not competitive even for cycles.
12
DF is bad
 Basically, if the current node has new edges, then
DF always chooses one of them.
 Otherwise, DF chooses the nearest new edge.
Proposition 1’
DF is not competitive even for cycles.
Proof.
origin
1
100
OPT(G) = 6
DF(G) = 103
1
1
 If the graph includes cycles, the problem would become non-trivial.
13
Best previous algorithm
ShortCut algorithm:
 proposed by Kalyanasundarama and Pruhs (TCS 130, 1994).
 It is shown that ShortCut achieves the competitive ratio of
16 for planar graphs.
ShortCut (planar graph )
 16
OPT(planar graph )
Basic strategy of ShortCut:
 the weighted nearest neighbor strategy (WNN).
 What is WNN?
14
Weighted Nearest Neighbor Algorithm
 Suppose that the searcher is currently on u.
Weighted Nearest Neighbor WNN
 If d1 + d2 <   d3, then
the searcher visits y;
 Otherwise,
the searcher visits v.
d1
y
x
d2
explored area
Nearest Neighbor NN
 sets  = 1
 WNN1
u
v
d3
15
Weighted Nearest Neighbor Algorithm
 Suppose that the searcher is currently on u.
Weighted Nearest Neighbor WNN
 If d1 + d2 <   d3, then
the searcher visits y;
 Otherwise,
the searcher visits v.
99
y
x
50
explored area
Nearest Neighbor NN
 sets  = 1, i.e., WNN1
 visits v since 99 +50 > 55
 worst case: its competitive ratio is (log n)
u
v
55
16
Weighted Nearest Neighbor Algorithm
 Suppose that the searcher is currently on u.
Weighted Nearest Neighbor WNN
 If d1 + d2 <   d3, then
the searcher visits y;
 Otherwise,
the searcher visits v.
99
y
x
50
explored area
ShortCut [KP94]
 sets  = 3, WNN3
 visits y since 99 + 50 < 3  50
 its competitive ratio is 16 for planar graphs
u
v
55
17
This paper
 Focuses the WNN strategy,
 Applies WNN to cycles,
 Investigates its ability more intensively.
d1
y
x
Weighted Nearest Neighbor WNN
 If d1 + d2 <   d3, then
the searcher visits y;
 Otherwise,
the searcher visits v.
d2
explored area
u
v
d3
18
Our problem
Online Graph Exploration Problem for Cycles
Initial Information:
 Only the partial information of
map is given
 the origin o
 its neighbor nodes
 the length of edge (o, u) for
each neighbor node u
Online Information:
 When the searcher visits a node u,
its neighbor nodes v’s, and the length
of edges (u, v)’s are obtained.
Goal:
 Minimize the total distance of the tour,
beginning at o, visiting all the nodes
at least once, and returning to o.
???
The gray area is a simple path,
but the searcher does not know
its shape.
19
Summary of Our Results
Upper bounds for cycles:
 NN (i.e., WNN1) achieves the competitive ratio of 1.5 for
cycles.
 Our analysis of the 1.5-competitive ratio is tight since we can
provide an instance for which the bound of 1.5 is attained.
Lower bounds for WNN:
 Setting  = 1 for WNN is the best for cycles, i.e.,
 if   1, the competitive ratio of WNN is at least 1.5.
Lower bound for general algorithms.
 No deterministic online algorithm has a competitive ratio less
than 1.25.
20
Cycles
 Let C = (V, E, l) be a cycle with |V| = n, |E| = n, and
edge-length l(e).
 Let L be the sum of the length of all edges in E.
 Let lmax be the maximum edge length
1
L  11 3  2  4  2
2
lmax  4
 13
1
4
3
2
21
Optimal Tour
 If the graph is a cycle, an optimal tour forms either
 a simple cycle including all n edges, or
 a U-turn tour including n – 1 different edges.
2
5
4
lmax  5
L  17
lmax  12 L
2
2
3
1
4
lmax  200
OPT (G)  L
 17
5
L  215
lmax  12 L
200
3
1
OPT (G)  2( L  lmax )
 30
22
Our Result (1)
Theorem 1:
WNN1 is 1.5-competitive for cycles.
Proof. There are two cases:
(Case 1) lmax < L/2
 OPT(G) = L
OPT
23
Our Result (1)
Theorem 1:
WNN1 is 1.5-competitive for cycles.
Proof. There are two cases:
(Case 1) lmax < L/2
 OPT(G) = L
 WNN1 needs at most L to visit all nodes,
and at most L/2 to go back to the origin.
WNN1  L  12 L
 32 L
WNN1
1
2
10
1
3
2
L 3

  1.5
L 2
5
24
Our Result (1)
Theorem 1:
WNN1 is 1.5-competitive for cycles.
Proof. Ttwo cases:
(Case 2) lmax >= L/2
 OPT(G) = 2(L – lmax)
 WNN1 needs at most 2(L – lmax) to visit
all nodes, and at most (L – lmax) to go
back to the origin.
WNN1  ( L  lmax )  ( L  lmax )  ( L  lmax )
 3( L  lmax )
3( L  lmax ) 3

  1.5
2( L  lmax ) 2
25
Our Result (2)
Theorem 2:
For any , the competitive ratio of WNN is at least 1.5 for
cycles.
Theorem 1:
WNN1 is 1.5-competitive for cycles.
From Theorems 1 and 2, it can be obtained that
 Setting  =1 for WNN is the best for cycles.
26
Our Result (2)
Theorem 2:
For any , the competitive ratio of WNN is at least 1.5 for
cycles.
Proof.
This theorem is shown by Lemmas 1 and 2:
Lemma 1:
For 0 <  < 1, the competitive ratio of WNN exceeds 1.5.
Lemma 2:
For 1 <= , the competitive ratio of WNN is at least 1.5.
27
Lemma 1
Lemma 1:
For 0 <  < 1, the competitive ratio of WNN exceeds 1.5.
Proof.
 Construct a hard cycle C such that
 the searcher of WNN goes
through the longest edge, and
 the searcher goes through the explored
edges several times, but
 OPT does not go through the
longest edge.
lmax
x
o
q
p1
p2
pk
y
28
Lemma 1
Lemma 1:
For 0 <  < 1, the competitive ratio of WNN exceeds 1.5.
Proof.
 Construct a hard cycle C such that
 the searcher of WNN goes
through the longest edge, and
 the searcher goes through the explored
edges several times, but
 OPT does not go through the
longest edge.
lmax
x
o
q
p1
p2
pk
y
29
Lemma 1
Lemma 1:
For 0 <  < 1, the competitive ratio of WNN exceeds 1.5.
Proof.
 Construct a hard cycle C such that
 the searcher of WNN goes
WNN  (2   ) L  8

through the longest edge, and
OPT
(1   ) L  8
 the searcher goes through the explored
2
edges several times, but

1 
 OPT does not go through the
longest edge.
 1. 5
lmax  12 L
x
lmax
o
q
p1
p2
pk
y
30
Lemma 2
Lemma 2:
For 1 <= , the competitive ratio of WNN is at least 1.5.
Proof.
 Construct a different hard cycle C such that
 the searcher of WNN goes
through the explored edges
many times, but
WNN 
 OPT goes through every edge
OPT
exactly once.
am
a2
a1
o
b1
3(2 2 m  2  2(m  1) )

2(2 2 m  1)
 1.5  o(1)
b2
bm
31
Theorems 1 and 2
Theorem 1:
WNN1 is 1.5-competitive for cycles.
Theorem 2:
For any , the competitive ratio of WNN is at least 1.5.
As a result,
 Setting  =1 for WNN is the best for cycles.
32
Our Result (3)
Theorem 3:
No online graph exploration algorithm has a competitive
ratio less than 1.25.
Proof. Consider two cycles.
ALG 5   0

 1.25  
OPT 4  2 0
ALG 10

 1.25
OPT
8
1
a
d
b
3
1
c
3
1
a
b
3
1
d
c
ε0
33
Summary and Future Work
Result 1: Upper and tight bounds for cycles
 NN (i.e.,WNN1) achieves the competitive ratio of 1.5 for cycles.
 Our analysis of the 1.5-competitive ratio is tight since we can provide an
instance for which the bound of 1.5 is attained.
Result 2: Lower bound for general algorithms
 No deterministic online algorithm has a competitive ratio less than 1.25.
Future Work




Different good online strategy for cycles.
Smaller competitive ratio than 16 for planar graphs.
Larger lower bound than 1.25 for general algorithms.
Competitive algorithm for general graphs.
34
Summary and Future Work
Result 1: Upper and tight bounds for cycles
 NN (i.e.,WNN1) achieves the competitive ratio of 1.5 for cycles.
 Our analysis of the 1.5-competitive ratio is tight since we can provide an
instance for which the bound of 1.5 is attained.
Result 2: Lower bound for general algorithms
 No deterministic online algorithm has a competitive ratio less than 1.25.
Future Work




Different good online strategy for cycles.
Smaller competitive ratio than 16 for planar graphs.
Larger lower bound than 1.25 for general algorithms.
Competitive algorithm for general graphs.
Thank you.
35