Title: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths
1Multiple-Source Shortest Paths in Planar Graphs
Allowing Negative Lengths
- Philip Klein
- Brown University
2Main Result
- For plane graph with boundary r1,,rs,O(n log n)
algorithm to find all shortest-path trees rooted
at the ris.
3Main Result
- For plane graph with boundary r1,,rs, O(n log
n) algorithm to find all shortest-path trees
rooted at the ris. implicit representation
4Main Result
- For plane graph with boundary r1,,rs, O(n log
n) algorithm to find all shortest-path trees
rooted at the ris. implicit representation
5Main Result
- For plane graph with boundary r1,,rs,O(n log n)
algorithm to find all shortest-path trees rooted
at the ris. implicit representation
- Negative lengths are ok
- Given k source-sink pairs (where each source is
an ri), can find corresponding distances in O((n
k) log n) time
6Some Applications
- Single-source shortest-path tree in planar graph
with some negative lengths O(n log n).
Previous bound O(n log3 n) Fakcharoenphol,
Rao - Testing feasibility of planar flow with multiple
sources and sinks, and upper and lower
capacities O(n log n). - Finding a minimum ratio cut in a planar graph
(used in, e.g., segmentation of images Cox, Rao,
Zhong) -
-
-
-
- O(n log n log CW) where C sum of costs, W sum
of weights.
7Some Applications
- Preprocessing a planar graph to admit O(
)-time exact distance queries O(n log2 n).
Previous bound Fakch., Rao O(n log3 n) - Preprocessing undirected planar graph to admit
O(e-1)-time approx. distance queries O(e-1n log2
n). Previous bound Thorup O(e-2n log3 n) - (similar improvement for directed graphs)
- Slightly faster dynamic algorithms for
planar-graph distances (improving on Fakch.,
Rao)
8Previous Work
Single-source shortest paths in planar graphs
with negative lengths
Lipton, Rose, Tarjan, 1979 O(n1.5)
Henzinger, Klein, Rao, Subramanian, 1997 O(n4/3 log (nL))
Fakcharoenphol, Rao, 2001 O(n log3 n)
9Previous Work
Multiple-source shortest paths in planar graphs
Schmidt, 1995 For special case of n-node grid
DAG, after O(n log n) preprocessing, can find
distance from any node in column 0 to any other
node in O(log n) time.
10Talk Overview
- Analysis technique O(n) representation of
multiple-source shortest-path trees - Shortest-path-update technique represent partial
solution by spanning tree, not by distance
labeling. - Unrelaxed-edge-selection technique use dynamic
tree in planar dual - Partial-solution-tree property Each path P in
tree is the shortest path to the right of P.
11Analysis Technique
- Nodes along boundary of graph
12Analysis Technique
13Analysis Technique
- Shortest paths to v dont cross
14Analysis Technique
- For each edge entering v, paths using the edge
start from consecutive ris.
15Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
16Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
17Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
18Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
19Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
20Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
21Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
22Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
23Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
24Analysis Technique
- As we iterate through nodes r1,,rs,edge used to
reach v rarely changes - Number of changes indegree(v)
25Analysis Technique
- Now consider shortest-path trees from r1,,rs.
26Analysis Technique
- Number of changes as we iterate through ris is
- indegree(v)
27Analysis Technique
- Number of changes as we iterate through ris is
- indegree(v), which is number of edges
28Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
29Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
- Length of a path from root to v through relaxed
edges is at least d(v). - To get shorter path to v, need to use at least
one unrelaxed edge.
30Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
- Relaxing edge uv means assigning d(u) len(uv)
to d(v)
31Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
- Relaxing edge uv means assigning d(u) len(uv)
to d(v)
32Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
- Relaxing edge uv means assigning d(u) len(uv)
to d(v) - After this assignment, uv is relaxed but edges vw
out of v might now be unrelaxed. - Updates to d(.) propagate slowly
33Traditional Shortest-path Algorithm
- Maintains an assignment d(.) of distance
estimates to nodes - An edge uv is unrelaxed if
- d(u) len(uv) lt d(v)
- Relaxing edge uv means assigning d(u) len(uv)
to d(v) - After this assignment, uv is relaxed but edges vw
out of v might now be unrelaxed. - Updates to d(.) propagate slowly
34New Approach
- Maintain a tentative shortest-path tree T rooted
at r - Each node except r has a parent edge in T
- Tree defines an assignment dT(.)
- dT(v) length of r-to-v path in T
- An edge uv is unrelaxed if
- dT(u) len(uv) lt dT(v)
- Relaxing an edge uv means replacing vs parent
edge in T with uv - Values of dT(.) automatically updated
35New Approach
- Maintain a tentative shortest-path tree T rooted
at r - Each node except r has a parent edge in T
- Tree defines an assignment dT(.)
- dT(v) length of r-to-v path in T
- An edge uv is unrelaxed if
- dT(u) len(uv) lt dT(v)
- Relaxing an edge uv means replacing vs parent
edge in T with uv - Values of dT(.) automatically updated
36Generic Single-Source Algorithm
- Start with some tree rooted at r.
- Repeat
- select an unrelaxed edge
- relax it
- Until none exist
- Questions
- Which tree to start with?
- How to find an unrelaxed edge?
- How much time is required?
37Generic Single-Source Algorithm
- Start with some tree rooted at r.
- Repeat
- select an unrelaxed edge
- relax it
- Until none exist
- Questions
- Which tree to start with?
- How to select an unrelaxed edge?
- How much time is required?
38Questions for Single-source Algorithm A Preview
- How to select an unrelaxed edge?
- Leafmost unrelaxed edge in dual spanning tree
- Use a dynamic tree to represent dual spanning
treeO(log n) amortized time per relaxation step - Which tree to start with?
- Rightmost-search tree
- How much time required?
- Specify invariant that guarantees O(n) relaxation
steps
39Planar Dual
- Every planar embedded graph has a dual graph
- Dual nodes primal faces
- Dual edge cross primal edges
40Planar Dual
- Every planar embedded graph has a dual graph
- Dual nodes primal faces
- Dual edge cross primal edges
- For any primal spanning tree T
41Planar Dual
- Every planar embedded graph has a dual graph
- Dual nodes primal faces
- Dual edge cross primal edges
- For any primal spanning tree T, duals of edges
not in T form a dual spanning tree T
42Planar Dual
- Every planar embedded graph has a dual graph
- Dual nodes primal faces
- Dual edge cross primal edges
- For any primal spanning tree T, duals of edges
not in T form a dual spanning tree T
43Planar Dual
- Every planar embedded graph has a dual graph
- Dual nodes primal faces
- Dual edge cross primal edges
- For any primal spanning tree T, duals of edges
not in T form a dual spanning tree T
44How to Select an Unrelaxed Edge
- Dual spanning tree T, rooted at infinite face
45How to Select an Unrelaxed Edge
- Dual spanning tree T, rooted at infinite face
46How to Select an Unrelaxed Edge
- Dual spanning tree T, rooted at infinite face
- Choose a leafmost unrelaxed edge
- (unrelaxed edge with no descendant unrelaxed edge)
47Choosing Unrelaxed Edge Implementation
- Use a dynamic tree data structure Sleator,
Tarjan to represent the dual tree T. - O(log n) time per operation
- Structure Operations
- Cut an edge, breaking a tree into two
- Join two trees, making the root of one into a
child of some node of the other - Evert a tree, changing its root
48Choosing Unrelaxed Edge Implementation
- Use a dynamic tree data structure Sleator,
Tarjan to represent the dual tree T. - O(log n) time per operation
- Structure Operations
- Cut an edge, breaking a tree into two
- Join two trees, making the root of one into a
child of some node of the other - Evert a tree, changing its root
49Choosing Unrelaxed Edge Implementation
- Use a dynamic tree data structure Sleator,
Tarjan to represent the dual tree T. - O(log n) time per operation
- Structure Operations
- Cut an edge, breaking a tree into two
- Join two trees, making the root of one into a
child of some node of the other - Evert a tree, changing its root
50Choosing Unrelaxed Edge Implementation
- Dynamic tree implicitly represents assignments of
costs to nodes - Cost operations
- search a v-to-root path for the minimum-cost node
- add a number ? to costs of all nodes in a
v-to-root path - We need some new features
51Choosing Unrelaxed Edge Using Dynamic Tree
- For each non-tree primal edge uv, define
- s(uv) dT(u) len(uv) dT(v)
- Measure of how relaxed the edge is.
- Unrelaxed edges have negative s values
52Choosing Unrelaxed Edge Using Dynamic Tree
- For each non-tree primal edge uv, define
- s(uv) dT(u) len(uv) dT(v)
- Measure of how relaxed the edge is.
- Unrelaxed edges have negative s values
- Dual edges same s values as primal edges
53Choosing Unrelaxed Edge Using Dynamic Tree
- For each non-tree primal edge uv, define
- s(uv) dT(u) len(uv) dT(v)
- Measure of how relaxed the edge is.
- Unrelaxed edges have negative s values
- Dual edges same s values as primal edges
- Use dynamic tree to represent dual tree F
- Dynamic tree implicitly represents s values
- Modify dynamic tree to support O(log n) search
for a leafmost edge with negative s value. - Can update s values in O(log n) time after
relaxation step.
54Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
55Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
56Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
57Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
58Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
59Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
60Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
- Let xy dual edge corresp. to uv
61Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
- Let xy dual edge corresp. to uv
62Modification of s Values in Dual Tree
- Relaxing edge wv reduces the value of dT(.) by
-s(wv) for v and vs descendents in T. - Replace vs parent edge uv in T with wv.
- Let xy dual edge corresp. to uv
- Must change s values along x-to-y path
63Modification of s Values in Dual Tree
- Orientation of dual edges reflect orientation of
primal edges
64Modification of s Values in Dual Tree
- Orientation of dual edges reflect orientation of
primal edges - Keep track of orientation of dual edges in dual
spanning tree
65Modification of s Values in Dual Tree
- Define dynamic-tree operation Given a node v
and a number ?, changeValue(v,?) changes the s
values of all edges e on the v-to-root path
? if e points towards root - ? if e
points away from root
66Modification of s Values in Dual Tree
- Define dynamic-tree operation Given a node v
and a number ?, changeValue(v,?) changes the s
values of all edges e on the v-to-root path - To modify s values in dual tree
- Set ? s(wv)
- Call
- changeValue(x, ?)
- changeValue(y, -?)
? if e points towards root - ? if e
points away from root
67Structural Changes in Dual Tree
- After modifying s values, use cut, evert, and
join to change dual tree when relaxing an edge.
68Structural Changes in Dual Tree
- After modifying s values, use cut, evert, and
join to change dual tree when relaxing an edge.
69Structural Changes in Dual Tree
- After modifying s values, use cut, evert, and
join to change dual tree when relaxing an edge.
70Structural Changes in Dual Tree
- After modifying s values, use cut, evert, and
join to change dual tree when relaxing an edge.
71Single-Source Algorithm
- Start with some tree rooted at r.
- Repeat
- select a leafmost unrelaxed edge
- relax it
- until none exist
- Questions
- Which tree to start with? (Later.)
- How to find a leafmost edge? Use the dual
dynamic tree. - How to bound time required? Each relaxation
requires amortized O(log n) time. Need to bound
number of relaxations.
72Single-Source Algorithm
- Start with some tree rooted at r.
- Repeat
- select a leafmost unrelaxed edge
- relax it
- until none exist
- Questions
- Which tree to start with? (Later.)
- How to find a leafmost edge? Use the dual
dynamic tree. - How to bound time required? Each relaxation
requires amortized O(log n) time. Need to bound
number of relaxations. - Theorem Each edge is relaxed at most once.
(Proof later)
73Notation Tv
- For a tree T and a node v, Tv denotes the
root-to-v path in T.
74The More Left Than Partial Order on s-to-t paths
- For a nodes s and t, we can define what it means
for one s-to-t path to be more left than another.
(Definition omitted comes from Weihe) Implies
paths dont cross.
75The More Left Than Partial Order on r-rooted
Trees
- Given two trees TL and TR, both rooted at r, we
say TL is to the left of TR if, for every node v,
the r-to-v path TLv is to the left of the
r-to-v path TRv.
76Right-First Search
- Ripphausen-Lipa, Wagner, Weihe
- Depth-first search where you explore outgoing
edges from right to left.
77Right-First Search
- Ripphausen-Lipa, Wagner, Weihe
- Depth-first search where you explore outgoing
edges from right to left.
78Right-First Search
- Ripphausen-Lipa, Wagner, Weihe
- Depth-first search where you explore outgoing
edges from right to left. - The right-first search tree T hasthe following
property - For any node v, the path Tv is the
rightmost root-to-v path.
79Single-Source Algorithm
- Start with right-first search tree
- Repeat
- select a leafmost unrelaxed edge
- relax it
- until none exist
- Questions
- Which tree to start with? (Rightmost-search tree)
- How to find a leafmost edge? Use the dual
dynamic tree. - How to bound time required? Each relaxation
requires amortized O(log n) time. Need to bound
number of relaxations. - Theorem Each edge is relaxed at most once.
(Proof)
80Analysis of Single-Source Algorithm
- Get a sequence T0, T1, T2, of trees.
- To show Each tree Ti1 is to the left of
previous tree Ti. - Hence, for each node v, each path Ti1v is to
the left of the previous path Ti v.
81Analysis of Single-Source Algorithm
- Get a sequence T0, T1, T2, of trees.
- To show Each tree Ti1 is to the left of
previous tree Ti. - Hence, for each node v, each path Ti1v is to
the left of the previous path Ti v. - Hence these paths use edges entering v in
clockwise order. - Use analysis technique outlined at start of talk.
82Invariant
- We say a tree T is right-short if, for every node
v, Tv is the unique shortest root-to-v path
that is to the right of Tv.
83Invariant
- We say a tree T is right-short if, for every node
v, Tv is the unique shortest root-to-v path
that is to the right of Tv.
84Invariant
- We say a tree T is right-short if, for every node
v, Tv is the unique shortest root-to-v path
that is to the right of Tv. - A right-first search tree is trivially
right-short.
85Invariant
- We say a tree T is right-short if, for every node
v, Tv is the unique shortest root-to-v path
that is to the right of Tv. - A right-first search tree is trivially
right-short. - Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge. Then T is right-short and is to the
left of T.
86- Consider an unrelaxed edge xy.
- Suppose the path Tx ? xy is to the right of
Ty.
- xy is unrelaxed gt Tx ? xy is shorter than
Ty. - Ty is not the shortest path to the right of
Ty. - T is not right-short.
87- Consider an unrelaxed edge xy.
- Suppose the path Tx ? xy is to the right of
Ty.
- xy is unrelaxed gt Tx ? xy is shorter than
Ty. - Ty is not the shortest path to the right of
Ty. - T is not right-short.
Lemma 1 If T is right-short and xy is unrelaxed
then Tx ? xy is to the left of Ty.
88- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is (1) to the left of T and is
(2) right-short. - Proof (1) Use Lemma 1 to show that T is to the
left of T
89- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is (1) right-short and is (2)
to the left of T. - Proof
- Edge xy forms a cycle with the tree.
90- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Edge xy forms a cycle with the tree.
- Cycle encloses a region R containing no
unrelaxed edges (since xy wasleafmost unrelaxed
edge).
91- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
92- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
- Then, for some node v, some path P to theright
of T v is no longer than T v.
93- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
- Then, for some node v, some path P to theright
of Tv is no longer than Tv. - Hence P shorter than Tv.
- But P cant be shorter by going tothe right of
Tv (would violateright-shortness of T)
94- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
- Then, for some node v, some path P to theright
of Tv is no longer than Tv. - Hence P shorter than Tv.
- But P cant be shorter by going tothe right of
Tv (would violate right-shortness of T) - And P cant be shorter by using an unrelaxed
edge inside R (no such edge)
95- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
- Then, for some node v, some path P to theright
of Tv is no longer than Tv. - Hence P shorter than Tv.
- But P cant be shorter by going tothe right of
Tv (would violateright-shortness of T) - And P cant be shorter by using an unrelaxed
edge inside R(no such edge)
96- Theorem Suppose T is right-short and T is
obtained from T by relaxing a leafmost unrelaxed
edge xy. Then T is right-short and is to the
left of T. - Proof
- Assume that T is not right-short.
- Then, for some node v, some path P to theright
of Tv is no longer than Tv. - Hence P shorter than Tv.
- But P cant be shorter by going tothe right of
Tv (would violateright-shortness of T) - And P cant be shorter by using an unrelaxed
edge inside R(no such edge) - Contradiction. Q.E.D.
97Multiple-Source Algorithm
- Order the nodes r1,r2,,r10 clockwise around
graph. - Add 8-cost edges from r10?r9,, r3?r2,r2?r1
- Start with some tree rooted at r1
- For i 1,2,
- Repeat
- select a leafmost unrelaxed edge
- relax it
- Until no unrelaxed edges remain
- Go from ri-rooted tree to ri1-rooted tree by
adding edge ri1 ? ri
98Analysis of Multiple-Source Algorithm
- Go from ri-rooted tree to ri1-rooted tree by
adding edge ri1?ri - Must show tree remains right-short.
- Must show same analysis technique applies to
entire sequence of trees.
99Multiple-Source Algorithm
- Start with some tree rooted at r1
- For i 1,2,
- Repeat
- find a leafmost unrelaxed edge
- relax it
- Until no unrelaxed edges remain
- Go from ri-rooted tree to ri1-rooted tree by
adding edge ri1 ? ri - How to find distances?
-
100How to Find Distances (in Multiple Source
Algorithm)
- Start with some tree rooted at r1
- For i 1,2,
- Repeat
- find a leafmost unrelaxed edge
- relax it
- Until no unrelaxed edges remain
- Go from ri-rooted tree to ri1-rooted tree by
adding edge ri1 ? ri - Idea use dynamic tree to represent tentative
shortest-path tree T. - To relax vw is to cut the current parent edge uv,
and then join the trees using vw. O(log n) time - Can query a node v to find sum of costs on
root-to-v path. O(log n) time - At the end of iteration I of the for-loop, can
query for distances from ri. - Amortized time for total of k queries O(k log n)
101Conclusion
- Conceptually simple algorithm (details in the
data structure!) - Analysis technique might be more generally
applicable - Can we compute arbitrary source-to-sink distances
in O(log n) time per distance?