Use dicts for the graph instead of sets