```
Reductions and Decomposition
Solving problems by reducing them to other problems.
Kevin Lin, with thanks to many others.
1
DAG Shortest Paths
Given a weighted DAG (possibly negative edge weights), find the single-source shortest paths tree from s to every other vertex in the graph.
Your algorithm should be faster than Dijkstra’s algorithm.
2
B
C
A
s
1
5
D
-4
2
4
0
1
2
4
Q
DAG Shortest Paths
Given a weighted DAG (possibly negative edge weights), find the single-source shortest paths tree from s to every other vertex in the graph.
Your algorithm should be faster than Dijkstra’s algorithm.
3
B
C
A
s
1
5
D
-4
2
4
0
1
2
4
A
Positive Integer-Weighted Shortest Paths
Given a weighted, directed graph (possibly cyclic) with positive integer edge weights, find the single-source shortest paths tree from s to every other vertex in the graph.
Your algorithm should be faster than Dijkstra’s algorithm on cyclic graphs.
4
Q
B
C
A
s
5
5
D
1
2
1
0
1
2
4
Positive Integer-Weighted Shortest Paths
Given a weighted, directed graph (possibly cyclic) with positive integer edge weights, find the single-source shortest paths tree from s to every other vertex in the graph.
Your algorithm should be faster than Dijkstra’s algorithm on cyclic graphs.
5
A
DAG Longest Paths
Given a weighted DAG (possibly negative edge weights), find the single-source longest paths tree from s to every other vertex in the graph.
Give the runtime of your algorithm.
6
Q
B
C
A
s
5
5
D
1
2
1
0
1
2
4
DAG Longest Paths
Given a weighted DAG (possibly negative edge weights), find the single-source longest paths tree from s to every other vertex in the graph.
Give the runtime of your algorithm.
7
A
Vertex Weights in Shortest Paths
How would you model vertex weights for shortest paths problems?
8
Q
v
b
e
x
Shortest Paths (Robert Sedgewick, Kevin Wayne/Princeton)
a
c
d
Vertex Weights in Shortest Paths
How would you model vertex weights for shortest paths problems?
9
A
v
b
e
x
Shortest Paths (Robert Sedgewick, Kevin Wayne/Princeton)
a
c
d
10
Q14 from COS 226 14sp Final (Solution)
11
Q12 from COS 226 15sp Final (Solution)
12
Longest Simple Paths in Arbitrary Graphs
It turns out that finding the longest simple path (containing no cycles) in a directed graph (possibly cyclic) is a “hard” problem. Best known algorithms involve brute force search.
Based on what we know about DAG longest paths, explain why this is much harder.
13
Q
Longest Simple Paths in Arbitrary Graphs
It turns out that finding the longest simple path (containing no cycles) in a directed graph (possibly cyclic) is a “hard” problem. Best known algorithms involve brute force search.
Based on what we know about DAG longest paths, explain why this is much harder.
14
A
```