Nessun titolo diapositiva

Maintaining Shortest Paths in
Digraphs with Arbitrary Arc Weights
C. Demetrescu
D. Frigioni
A. Marchetti-Spaccamela
U. Nanni
University of Rome “La Sapienza”
Fully Dynamic Single-source Shortest Paths
Let: G = (V,E,w) weighted directed graph
w(u,v)  
sV
weight of edge (u,v)
source node
Perform intermixed sequence of operations:
Increase(u,v,): Increase weight w(u,v) by 
Decrease(u,v,): Decrease weight w(u,v) by 
Query(v):
Return shortest path
from s to v in G
A Simple-minded Method
After each Increase or Decrease:
use best static algorithm [Bellman-Ford]
to recompute from scratch shortest paths in G
 O(m·n) worst-case time ( n=|V|, m=|E| )
Can we do any better?
An Asymptotically Faster Method
After each Increase or Decrease:
1. Use a reweighting technique to obtain from G a
new graph G* with nonnegative weights  O(m)
2. Perform Dijkstra’s algorithm to compute from
scratch shortest paths in G*  O(m+n·log n)
3. Retrieve shortest paths in G from shortest
paths in G*  O(n)
Thus: O(m·n)
O(m+n·log n)
A Reweighting Technique
G = (V,E,w)
[Edmonds, Karp]
w:E
Reweighting
G* = (V,E,w*)
h : V   (arbitrary)
w*(u,v) = w(u,v) + h(u) - h(v)
Lemma 1:
p is a shortest path in G  p is a shortest path in G*
A Reweighting Technique
[Ramalingam and Reps]
If we choose:
h(v) := d(v) = distance from s to v
Lemma 2:
w*(u,v) = w(u,v) + d(u) - d(v) ≥ 0
Proof:
d(v) ≤ w(u,v) + d(u)
0 ≤ w(u,v) + d(u) - d(v)
[Bellman]
Weight decrease [Ramalingam and Reps]
Decreasing the weight
of an edge might allow
to find better paths
out of T(v)
u
-
v
Ramalingam and Reps:
apply Dijkstra’s alg.
to the graph G*
(with modified weights)
T(v)
Weight decrease (cont.)
There exists a negat.
cycle if and only if
v is labelled again
u
Ideas of ownership and
k-bounded account. fct.
can be applied reducing
w.c.running time
v
T(v)
Weight increase: Output Bounded
Analysis
Increase(u,v,+)
ss
Heuristic:
Dijkstra only on nodes in T(v)
uu
+
Output bounded:
Dijkstra only on nodes
which change distance
vv
P'(w)
+
w
T(s)
T'(s)
T(v)
T'(v)
Algorithms Under Evaluation
Name
Technique
Update time
BF
Simple-minded method [Bellman-Ford]
O(m·n)
DF
Reweighting method + Heuristic
O(m+n·log n)
RR
Reweighting method + Output Bounded
(Does not deal with zero length cycles)
O(m+n·log n)
[Ramalingam, Reps]
DFMN
Reweighting method + Output Bounded
[Frigioni, Marchetti, Nanni]
O(m+n·log n)
DF vs RR/DFMN
Increase:
L  nodes in T(v)
Heuristic
RR/DFMN
DF
Remove from L
nodes which don’t
change distance
Compute G* induced by nodes in L
Run Dijkstra on G*
OutputBounded
Reweighting
Goals of Experimentation
Look for hints about questions like:
1
We know that O(m+n·log n)
is better than O(m·n) ...
… but what about constant factors?
2
DFMN and RR are efficient
in output-bounded complexity ...
…but is it useful in practice?
DF vs RR/DFMN
Increase:
L  nodes in T(v)
Heuristic
RR/DFMN
Is it useful?
DF
Remove from L
nodes which don’t
change distance
Compute G* induced by nodes in L
Run Dijkstra on G*
OutputBounded
Reweighting
Experimental Setup
Experimental platform:
- C++ using LEDA, g++ compiler
- UNIX Solaris on SPARC Ultra 10 at 300 Mhz
Test sets:
- Random graphs & random update sequences
(Use potentials technique to avoid negative
and zero-length cycles)
Performance indicators:
- Running time (msec)
- # nodes processed by Dijkstra’s algorithm
Constant Factors Are Small
Average Running Time per Operation (msec)
1000
BFM
625.325
DFMN
353.704
RR
100
175.012
DF
67.831
11.384
17.984
10
7.354
5.79
3.34
1.478
6.108
7.383
3.966
2.191
1.137
1
10.784
8.918
4.147
13.744
0.807
m=0.5n2 , Edge Weights in [-1000,1000]
0.1
0
100
200
300
Number of Nodes
400
500
600
# Nodes Processed by Dijkstra’s Algo
Average Processed Nodes per Operation
6
5.16
DF
5
DFMN/RR
4.35
4.45
4.89
3.78
4
4.02
3.21
3.65
2.84
3
2.09
2.84
2.14
2
+
2.03
1.46
1
0.78
0.9
n=300, m=0.5n 2=45000
0
2
4
6
8
Arc Weight Interval [-2 k,2 k]
10
12
The Range of Arc Weights Is Important
Average Running Time per Operation (msec)
9
8.261
DFMN
8
RR
7
6.941
DF
6.549
6
6.647
5.481
5.547
5
4.484
5.068
4.501
3.864
4
4.037
3.034
3
2.63
2
1.387
3.813
3.882
3.328
2.484
2.816
1.969
1.944
1
3.008
2.318
1.588
n=300, m=0.5n2 =45000
k
0
2
4
6
8
Arc Weight Interval [-2 k,2k]
10
12
Small Arc Weights Range
4
Average Running Time per Operation (msec)
3.98
3.437
DFMN
RR
3
2.963
DF
2.698
2.435
1.898
2
1.899
1.342
1.682
1.655
1.377
1
0.821
1.057
0.645
0.517
0.479
0.595
0.572
300 Nodes, Edge Weights in [-10,10]
0
0
1
2
3
4
5
6
Number of Edges x 10000
7
8
9
Large Arc Weights Range
Average Running Time per Operation (msec)
14
13.706
300 Nodes, Edge Weights in [-1000,1000]
12
DFMN
10.606
10.686
RR
10
DF
8.357
8
7.265
7.309
6
5.887
5.679
4.528
4
3.954
3.74
2.462
1.453
2
0.824
0.758
0 0.58
0
1.279
0.887
1
2
3
4
5
Number of Edges
6
7
8
9
Extreme Case: All Zero-length Cycles...
Average Running Time per Operation (msec)
1.2
1.133
1.081
DFMN
1
0.937
DF
0.853
0.829
0.8
0.689
0.7
0.574
0.6
0.568
0.472
0.4
n=2000, Arc Weights in [-10,10]
0.2
1
3
5
7
Number of Edges x 10000
9
11
Conclusions
Dynamic algorithms based on the
reweighting technique are very useful
In general, the simpler, the faster
Output bounded is useful for
small ranges of arc weights
What happens on real test sets?
What happens on larger test sets?