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



Decorator to generate a numpy.random.RandomState instance.

Argument position random_state_index is processed by create_random_state. The result is a numpy.random.RandomState instance.

Parameters:random_state_index (int) – Location of the random_state argument in args that is to be used to generate the numpy.random.RandomState instance. Even if the argument is a named positional argument (with a default value), you must specify its index as a positional argument.
Returns:_random_state – Function whose random_state keyword argument is a RandomState instance.
Return type:function


Decorate functions like this:

def random_float(random_state=None):
    return random_state.rand()

def random_array(dims, random_state=1):
    return random_state.rand(*dims)

See also