def create_degree_sequence(n, sfunction=None, max_tries=50, **kwds):
    tries=0
    max_deg=n
    while tries < max_tries:
        trialseq=sfunction(n,**kwds)
        # round to integer values in the range [0,max_deg]
        seq=[min(max_deg, max( int(round(s)),0 )) for s in trialseq]
        # if graphical return, else throw away and try again
        if nx.is_valid_degree_sequence(seq):
            return seq
        tries+=1
    raise nx.NetworkXError(\
          "Exceeded max (%d) attempts at a valid sequence."%max_tries)


# The same helpers for choosing random sequences from distributions
# uses Python's random module
# http://www.python.org/doc/current/lib/module-random.html
Creates a cursor that logs all queries in self.queries_log.
dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/utils/random_sequence.py/create_degree_sequence--crossover with--dataset/ETHPy150Open django/django/django/db/backends/base/base.py/BaseDatabaseWrapper.make_debug_cursor