0% found this document useful (0 votes)
8 views2 pages

Lab 16

Uploaded by

shihyunnam7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Lab 16

Uploaded by

shihyunnam7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ECE 374 B Lab 16 - Shortest paths I Fall 2023

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.

4. There are n galaxies connected by m intergalactic teleport-ways. Each teleport-way joins


two galaxies and can be traversed in both directions. However, the company that runs the
teleport-ways has established an extremely lucrative cost structure: Anyone can teleport
further from their home galaxy at no cost whatsoever, but teleporting toward their home
galaxy is prohibitively expensive.
Judy has decided to take a sabbatical tour of the universe by visiting as many galaxies
as possible, starting at her home galaxy. To save on travel expenses, she wants to teleport
away from her home galaxy at every step, except for the very last teleport home.
Describe and analyze an algorithm to compute the maximum number of galaxies that
Judy can visit. Your input consists of an undirected graph G with n vertices and m edges
describing the teleport-way network, an integer 1 ≤ s ≤ n identifying Judy’s home galaxy,
and an array D[1 .. n] containing the distances of each galaxy from s.

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.

You might also like