Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

weighted_choice

weighted_choice(mapping)[source]

Return a single element from a weighted sample.

The input is a dictionary of items with weights as values.