Top Banner
Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University
101

Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Dec 28, 2015

Download

Documents

Christal West
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths

Philip KleinBrown University

Page 2: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Main Result

For plane graph with boundary r1,…,rs,O(n log n) algorithm to find all shortest-path trees rooted at the ri’s.

Page 3: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Main Result

For plane graph with boundary r1,…,rs, O(n log n) algorithm to find* all shortest-path trees rooted at the ri’s.

*implicit representation

Page 4: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Main Result

For plane graph with boundary r1,…,rs, O(n log n) algorithm to find* all shortest-path trees rooted at the ri’s.

*implicit representation

– Negative lengths are ok

Page 5: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Main Result

For plane graph with boundary r1,…,rs,O(n log n) algorithm to find* all shortest-path trees rooted at the ri’s.

*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

Page 6: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Some 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.

Page 7: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Some 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(ε-1)-time approx. distance queries: O(ε-1n log2 n). Previous bound [Thorup]: O(ε-2n log3 n)

(similar improvement for directed graphs)

• Slightly faster dynamic algorithms for planar-graph distances (improving on [Fakch., Rao])

n

Page 8: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Previous Work

[Lipton, Rose, Tarjan, 1979]: O(n1.5)

[Henzinger, Klein, Rao, Subramanian, 1997]:

O(n4/3 log (nL))

[Fakcharoenphol, Rao, 2001]:

O(n log3 n)

Single-source shortest paths in planar graphs with negative lengths:

Page 9: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Previous WorkMultiple-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.

Page 10: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Talk 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.

Page 11: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Nodes along boundary of graph

Analysis Technique

Page 12: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Fix a node at v

Analysis Technique

Page 13: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Shortest paths to v don’t cross

Analysis Technique

Page 14: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

For each edge entering v, paths using the edge start from consecutive ri’s.

Analysis Technique

Page 15: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 16: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 17: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 18: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 19: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 20: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 21: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 22: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 23: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 24: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

As we iterate through nodes r1,…,rs,edge used to reach v rarely changes:

Number of changes ≤ indegree(v)

Analysis Technique

Page 25: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Now consider shortest-path trees from r1,…,rs.

Analysis Technique

Page 26: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Number of changes as we iterate through ri’s is: indegree(v)

v

Analysis Technique

Page 27: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Number of changes as we iterate through ri’s is: indegree(v), which is number of edges

v

Analysis Technique

Page 28: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < d(v)

Page 29: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < 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.

Page 30: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < d(v)

• Relaxing edge uv means assigning d(u) + len(uv) to d(v)

Page 31: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < d(v)

• Relaxing edge uv means assigning d(u) + len(uv) to d(v)

Page 32: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < 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

Page 33: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Traditional Shortest-path Algorithm

• Maintains an assignment d(.) of distance estimates to nodes

• An edge uv is unrelaxed if

d(u) + len(uv) < 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

Page 34: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

New 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) < dT(v)

• Relaxing an edge uv means replacing v’s parent edge in T with uv

• Values of dT(.) automatically updated

Page 35: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

New 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) < dT(v)

• Relaxing an edge uv means replacing v’s parent edge in T with uv

• Values of dT(.) automatically updated

Page 36: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Generic 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?

Page 37: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Generic 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?

Page 38: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Questions 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 tree:

O(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

Page 39: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Planar Dual

• Every planar embedded graph has a dual graph:– Dual nodes = primal faces– Dual edge cross primal edges

Page 40: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Planar Dual

• Every planar embedded graph has a dual graph:– Dual nodes = primal faces– Dual edge cross primal edges

• For any primal spanning tree T

Page 41: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Planar 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*

Page 42: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Planar 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*

Page 43: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Planar 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*

Page 44: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Dual spanning tree T*, rooted at infinite face

How to Select an Unrelaxed Edge

Page 45: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

How to Select an Unrelaxed Edge

Dual spanning tree T*, rooted at infinite face

Page 46: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

How 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)

Page 47: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing 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

Page 48: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing 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

Page 49: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing 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

Page 50: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing 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…

Page 51: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing Unrelaxed Edge Using Dynamic Tree

For each non-tree primal edge uv, define

σ(uv) = dT(u) + len(uv) – dT(v)

Measure of how relaxed the edge is.

Unrelaxed edges have negative σ values

Page 52: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing Unrelaxed Edge Using Dynamic Tree

For each non-tree primal edge uv, define

σ(uv) = dT(u) + len(uv) – dT(v)

Measure of how relaxed the edge is.

Unrelaxed edges have negative σ values

Dual edges: same σ values as primal edges

Page 53: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Choosing Unrelaxed Edge Using Dynamic Tree

For each non-tree primal edge uv, define

σ(uv) = dT(u) + len(uv) – dT(v)

Measure of how relaxed the edge is.

Unrelaxed edges have negative σ values

Dual edges: same σ values as primal edges

Use dynamic tree to represent dual tree F– Dynamic tree implicitly represents σ values– Modify dynamic tree to support O(log n) search for a leafmost

edge with negative σ value.– Can update σ values in O(log n) time after relaxation step….

Page 54: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 55: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 56: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 57: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 58: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 59: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

Page 60: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

• Let xy := dual edge corresp. to uv

Page 61: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

• Let xy := dual edge corresp. to uv

Page 62: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Relaxing edge wv reduces the value of dT(.) by -σ(wv) for v and v’s descendents in T.

• Replace v’s parent edge uv in T with wv.

• Let xy := dual edge corresp. to uv

• Must change σ values along x-to-y path

Page 63: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Orientation of dual edges reflect orientation of primal edges

Page 64: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Orientation of dual edges reflect orientation of primal edges

• Keep track of orientation of dual edges in dual spanning tree

Page 65: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Define dynamic-tree operation: Given a node v and a number Δ, changeValue(v,Δ) changes the σ values of all edges e on the v-to-root path:

)(:)( ee { Δ if e points towards root- Δ if e points away from root

Page 66: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Modification of σ Values in Dual Tree

• Define dynamic-tree operation: Given a node v and a number Δ, changeValue(v,Δ) changes the σ values of all edges e on the v-to-root path:

• To modify σ values in dual tree: Set Δ = σ(wv) Call:

• changeValue(x, Δ)• changeValue(y, -Δ)

)(:)( ee { Δ if e points towards root- Δ if e points away from root

Page 67: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Structural Changes in Dual Tree

• After modifying σ values, use cut, evert, and join to change dual tree when relaxing an edge.

Page 68: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Structural Changes in Dual Tree

• After modifying σ values, use cut, evert, and join to change dual tree when relaxing an edge.

Page 69: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Structural Changes in Dual Tree

• After modifying σ values, use cut, evert, and join to change dual tree when relaxing an edge.

Page 70: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Structural Changes in Dual Tree

• After modifying σ values, use cut, evert, and join to change dual tree when relaxing an edge.

Page 71: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Single-Source AlgorithmStart with some tree rooted at r.Repeat

select a leafmost unrelaxed edgerelax it

until none existQuestions:• 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.

Page 72: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Single-Source AlgorithmStart with some tree rooted at r.Repeat

select a leafmost unrelaxed edgerelax it

until none existQuestions:• 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)

Page 73: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Notation: T[v]

• For a tree T and a node v, T[v] denotes the root-to-v path in T.

Page 74: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

The “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 don’t cross.

Page 75: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

The “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 TL[v] is to the left of the r-to-v path TR[v].

Page 76: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Right-First Search

[Ripphausen-Lipa, Wagner, Weihe]

• Depth-first search where you explore outgoing edges from right to left.

Page 77: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Right-First Search

[Ripphausen-Lipa, Wagner, Weihe]

• Depth-first search where you explore outgoing edges from right to left.

Page 78: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Right-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 T[v] is the rightmost root-to-v path.

Page 79: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Single-Source AlgorithmStart with right-first search treeRepeat

select a leafmost unrelaxed edgerelax it

until none existQuestions:• 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…)

Page 80: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Analysis of Single-Source Algorithm

• Get a sequence T0, T1, T2, … of trees.

• To show: Each tree Ti+1 is to the left of previous tree Ti.

• Hence, for each node v, each path Ti+1[v] is to the left of the previous path Ti [v].

Page 81: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Analysis of Single-Source Algorithm

• Get a sequence T0, T1, T2, … of trees.

• To show: Each tree Ti+1 is to the left of previous tree Ti.

• Hence, for each node v, each path Ti+1[v] 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.

Page 82: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Invariant

• We say a tree T is right-short if, for every node v, T[v] is the unique shortest root-to-v path that is to the right of T[v].

Page 83: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Invariant

• We say a tree T is right-short if, for every node v, T[v] is the unique shortest root-to-v path that is to the right of T[v].

Page 84: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Invariant

• We say a tree T is right-short if, for every node v, T[v] is the unique shortest root-to-v path that is to the right of T[v].

• A right-first search tree is trivially right-short.

Page 85: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Invariant

• We say a tree T is right-short if, for every node v, T[v] is the unique shortest root-to-v path that is to the right of T[v].

• 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.

Page 86: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Consider an unrelaxed edge xy.

Suppose the path T[x] ◦ xy is to the right of T[y].

xy is unrelaxed => T[x] ◦ xy is shorter than T[y].T[y] is not the shortest path to the right of T[y].T is not right-short.

Page 87: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Consider an unrelaxed edge xy.

Suppose the path T[x] ◦ xy is to the right of T[y].

Lemma 1: If T is right-short and xy is unrelaxed then T[x] ◦ xy is to the left of T[y].

xy is unrelaxed => T[x] ◦ xy is shorter than T[y].T[y] is not the shortest path to the right of T[y].T is not right-short.

Page 88: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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…

Page 89: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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.

Page 90: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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).

Page 91: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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.

Page 92: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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].

Page 93: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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].

Hence P shorter than T[v].

But P can’t be shorter by going tothe right of T[v] (would violateright-shortness of T)

Page 94: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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].

Hence P shorter than T[v].

But P can’t be shorter by going tothe right of T[v] (would violate right-shortness of T)

And P can’t be shorter by using an unrelaxed edge inside R (no such edge)

Page 95: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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].

Hence P shorter than T[v].

But P can’t be shorter by going tothe right of T[v] (would violateright-shortness of T)

And P can’t be shorter by using an unrelaxed edge inside R(no such edge)

Page 96: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

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].

Hence P shorter than T[v].

But P can’t be shorter by going tothe right of T[v] (would violateright-shortness of T)

And P can’t be shorter by using an unrelaxed edge inside R(no such edge)

Contradiction. Q.E.D.

Page 97: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Multiple-Source Algorithm• Order the nodes r1,r2,…,r10 clockwise around graph.• Add ∞-cost edges from r10r9,…, r3r2,r2r1

• Start with some tree rooted at r1

• For i = 1,2,…Repeat

select a leafmost unrelaxed edgerelax it

Until no unrelaxed edges remainGo from ri-rooted tree to ri+1-rooted

tree by adding edge ri+1 ri

Page 98: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Analysis of Multiple-Source Algorithm

Go from ri-rooted tree to ri+1-rooted tree by adding edge ri+1ri

1. Must show tree remains right-short.

2. Must show same analysis technique applies to entire sequence of trees.

Page 99: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Multiple-Source Algorithm

Start with some tree rooted at r1

For i = 1,2,…Repeat find a leafmost unrelaxed edge relax itUntil no unrelaxed edges remain

Go from ri-rooted tree to ri+1-rooted tree by adding edge ri+1 ri

How to find distances?

Page 100: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

How 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 ri+1-rooted tree by adding edge ri+1 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)

Page 101: Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.

Conclusion

• 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?