将多对一映射转换为一对多映射。
many_to_one 必须是其键和值均为 hashable .
many_to_one
返回值是字典映射值 many_to_one 到键集,从 many_to_one 有这个价值的。
实例
>>> from networkx.utils import groups >>> many_to_one = {"a": 1, "b": 1, "c": 2, "d": 3, "e": 3} >>> groups(many_to_one) {1: {'a', 'b'}, 2: {'c'}, 3: {'e', 'd'}}