Lecture 16 - Problems

Goals:

  1. Is there more than one way to write the set representation of the same undirected graph? Give an example, or say why not. What about for a directed graph?
  2. Social networks are naturally modeled as graphs, where people are nodes and social connections form the edges. On Facebook, social connections take the form of “friendship”, where both Person A and Person B must agree to be friends. On Twitter, Person A can “follow” Person B, independently of whether Person B also follows Person A. What is the difference between these two graphs in terms of the graph terminology from lecture?
  3. What is the technical term for the number of Facebook friends a person has?
  4. What is the technical term for the number of followers a person has on Twitter?

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.

  1. What is the runtime of iterating over all edges?

  2. 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\)?

  3. What is the asymptotic storage space required to represent \(G\)?

  4. 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?

  5. Suppose a directed graph H has \(n\) nodes and is strongly connected. What’s the smallest possible value of \(|E|\)?

  6. Graphs are often used in epidemiology. How might you use graphs to simulate the spread of a disease?

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