Let \(G = (V, E)\) be an undirected graph with \(|V| = v\) and \(|E| = e\). For Problems 5, 6, and 7, give two answers: one if \(G\) is represented as an adjacency list and another if \(G\) is represented as an adjacency matrix.
What is the runtime of iterating over all edges?
Suppose \(x\) and \(y\) are nodes in \(G\) and node \(x\) has degree \(k\). What is the runtime of determining whether there is an edge from \(x\) to \(y\)?
What is the asymptotic storage space required to represent \(G\)?
Suppose G is connected. What are the smallest and largest possible values of \(|E|\)? Considering this and your answer to the prior question, under what circumstances would you be likely to prefer an adjacency list over an adjacency matrix, and vice versa?
Suppose a directed graph H has \(n\) nodes and is strongly connected. What’s the smallest possible value of \(|E|\)?
Graphs are often used in epidemiology. How might you use graphs to simulate the spread of a disease?
How might you use graphs to aid in contact tracing (i.e., to help track who may be infected, given a set of people who are known to have a contagious disease)?