import collections


def filter_by_weight(graph, min_weight):
  """Ensure edges >= min_weight are all that's left."""
  new_graph = collections.defaultdict(dict)

  for u in graph:
    for i in graph[u]:
      if graph[u][i] >= min_weight:
        new_graph[u][i] = graph[u][i]

  return new_graph