[G2] Adjacency lists (1 pt) [00LY]

Given a simple graph G, an adjacency list representation for G consists of a map (aka dictionary) associating each vertex with the list (or set) of all its adjacent neighbors. In other words, using Java-like notation, Map<Vertex, List<Vertex> >.

  1. Make a drawing of the graph represented by the map \{ 1 \mapsto [3,4], 2 \mapsto [3], 3 \mapsto [1, 2, 4], 4 \mapsto [1, 3] \}.
  2. Given a vertex u and an adjacency list representation of a graph G, how long does it take to list all the neighbors of u: \Theta (n), or \Theta (\deg (u))? Why?
  3. Explain how to generalize adjacency lists to represent directed graphs.
  4. Explain how to generalize adjacency lists to represent weighted graphs.