Lab 16
Lab 16
1. Given a directed-acyclic-graph (G = (V, E)) with integer (positive or negative) edge weights:
(a) Give an algorithm to find the shortest path from a node s to a node t.
(b) Give an algorithm to find the longest path from a node s to a node t.
2. Given a directed graph G = (V, E) with non-negative edge lengths ℓ(e), e ∈ E and a node
s ∈ V , describe an algorithm to find the length of a shortest cycle containing the node s.
3. Suppose we have a collection of cities and different airlines offer flights between various
pairs of cities. Some airlines only fly between some pairs of cities. Some pairs of cities are
served by many airlines. Each airline charges perhaps different amounts for their one-way
tickets.
• Suppose you’d like to get from City A to City B at the least total cost. Describe an
efficient solution. (Your solution may change planes to a different airline as needed.)
• It turns out that airports charge usage taxes. Different airports may charge different
amounts in tax. Your cost of traveling from A to B now includes all of the flight costs,
plus all of the taxes of the airports that you stopover along the way from A to B. Model
this as a graph problem and give an efficient solution to find the least cost way to get
from A to B.
1
ECE 374 B Lab 16 - Shortest paths I Fall 2023
To think about later: You probably heard of the phrase “six degrees of separation” and the
“small world” phenomenon; see https://en.wikipedia.org/wiki/Six_degrees_of_separation. The
idea is that in many interesting networks people or objects are within a small distance of each
other. At the same time we believe in “locality” in that each person may only a small number of
people compared to the total population. The next two problems explore the tradeoffs between
diameter and degree in a graph to explore this in a more quantitative fashion.
5. Suppose G is a graph with maximum degree d. The diameter of the graph is maxu,v dist(u, v).
Prove that the diameter of the graph is Ω(logd n) where n is the number of nodes. It is
easier to consider d = 5 or some other small constant for simplicity. Hint: Consider the
BFS layers starting at any vertex v.
The point of the problem is to show that if all degrees are small then the diameter must
grow with the number of nodes.
6. Suppose the diameter of an undirected simple graph is d. Prove that there is a node with
degree at most 3n/d. Hint: Consider the BFS layers for the pair defining the diameter. It is
easier to prove a bound such as 9n/d.
This problem is to show you that if the diameter is small then there must be a large degree
node.