This documents the development version of NetworkX. Documentation for the current release can be found here.



Converts a many-to-one mapping into a one-to-many mapping.

many_to_one must be a dictionary whose keys and values are all hashable.

The return value is a dictionary mapping values from many_to_one to sets of keys from many_to_one that have that value.

For example:

>>> 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: {'d', 'e'}}