0

当我运行下面的代码时,出现溢出错误。我在 random_sequence.py 模块的源代码(round(xmin * u,6))中使用了round方法对大数字进行舍入,但它不起作用。我怎样才能解决问题并得到结果?

>
    
    import numpy as np
    import networkx.generators.community as NGC

     N=100
     average_k=15
     max_comm_size=0.2*N
     min_com_size=0.25*max_comm_size
     comm_size_distr_exp=1.01
     degree_dist_exp=2
     degree_dist_exp=2
     mixing_parameter=np.random.uniform(0.2,0.8,1)
     LFR_g=NGC.LFR_benchmark_graph(N,degree_dist_exp,comm_size_distr_exp,mixing_parameter,average_k,None,None,min_com_size,max_comm_size,seed=5)
    communities = {frozenset(LFR_g.nodes[v]["community"]) for v in LFR_g}
  

 Blockquote

错误如下:

...
     File "<decorator-gen-44>", line 2, in LFR_benchmark_graph
          File "c:\users\far\networkx\networkx\utils\decorators.py", line 469, in _random_state
            return func(*new_args, **kwargs)
          File "c:\users\far\networkx\networkx\generators\community.py", line 1039, in LFR_benchmark_graph
            comms = _powerlaw_sequence(tau2, low, high, condition, length, max_iters, seed)
          File "c:\users\far\networkx\networkx\generators\community.py", line 694, in _powerlaw_sequence
            seq.append(_zipf_rv_below(gamma, low, high, seed))
          File "c:\users\far\networkx\networkx\generators\community.py", line 665, in _zipf_rv_below
            result = nx.utils.zipf_rv(gamma, xmin, seed)
          File "<decorator-gen-4>", line 2, in zipf_rv
          File "c:\users\far\networkx\networkx\utils\decorators.py", line 469, in _random_state
               return func(*new_args, **kwargs)
            File "c:\users\far\networkx\networkx\utils\random_sequence.py", line 83, in zipf_rv
               x = int(xmin * u ** round(-(1.0 / a1),6))
            OverflowError: (34, 'Result too large')
4

0 回答 0