def construct_backwards_adjacency_list(adjacency_list):
  """
  Create an adjacency list for traversing a graph
  backwards

  The resulting adjacency dictionary maps
  vertices to each vertex with an edge
  pointing to them

  """
  backwards_adjacency_list = {}
  for u in adjacency_list:
    for v in adjacency_list[u]:
      try:
        backwards_adjacency_list[v].add(u)
      except:
        backwards_adjacency_list[v] = {u}
  return backwards_adjacency_list