K i_dZddlZddlZddlZddlmZgdZejdddZ ejdddZ ed ejdddd Z ed ejdddd Z ed ejdddd Z edejddddZejdddZejdddZed ejdd ddZdZdZdZdZdZedejdd ddZy)zBGenerators for classes of graphs used in studying social networks.N)py_random_state) caveman_graphconnected_caveman_graphrelaxed_caveman_graphrandom_partition_graphplanted_partition_graphgaussian_random_partition_graphring_of_cliqueswindmill_graphstochastic_block_modelLFR_benchmark_graphT)graphs returns_graphctj||z}|dkDrItd||z|D]6}tjt|||zd}|j |8|S)a8Returns a caveman graph of `l` cliques of size `k`. Parameters ---------- l : int Number of cliques k : int Size of cliques Returns ------- G : NetworkX Graph caveman graph Notes ----- This returns an undirected graph, it can be converted to a directed graph using :func:`nx.to_directed`, or a multigraph using ``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is described in [1]_ and it is unclear which of the directed generalizations is most useful. Examples -------- >>> G = nx.caveman_graph(3, 3) See also -------- connected_caveman_graph References ---------- .. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.' Amer. J. Soc. 105, 493-527, 1999. r)nx empty_graphrange itertools combinationsadd_edges_from)lkGstartedgess c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/networkx/generators/community.pyrrslN q1uA1u1a!eQ' $E**5 +BAFE  U # $ Hc|dkrtjdtj||}td||z|D]2}|j ||dz|j ||dz ||zz4|S)aMReturns a connected caveman graph of `l` cliques of size `k`. The connected caveman graph is formed by creating `n` cliques of size `k`, then a single edge in each clique is rewired to a node in an adjacent clique. Parameters ---------- l : int number of cliques k : int size of cliques (k at least 2 or NetworkXError is raised) Returns ------- G : NetworkX Graph connected caveman graph Raises ------ NetworkXError If the size of cliques `k` is smaller than 2. Notes ----- This returns an undirected graph, it can be converted to a directed graph using :func:`nx.to_directed`, or a multigraph using ``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is described in [1]_ and it is unclear which of the directed generalizations is most useful. Examples -------- >>> G = nx.connected_caveman_graph(3, 3) References ---------- .. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.' Amer. J. Soc. 105, 493-527, 1999. rzDThe size of cliques in a connected caveman graph must be at least 2.rr)r NetworkXErrorrr remove_edgeadd_edge)rrrrs rrrFsT 1u R   AAq!a%#1 eUQY' 5519Q/01 Hrc0tj||}t|}|jD]a\}}|j |ks|j |}|j ||r>|j|||j||c|S)aReturns a relaxed caveman graph. A relaxed caveman graph starts with `l` cliques of size `k`. Edges are then randomly rewired with probability `p` to link different cliques. Parameters ---------- l : int Number of groups k : int Size of cliques p : float Probability of rewiring each edge. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. Returns ------- G : NetworkX Graph Relaxed Caveman Graph Raises ------ NetworkXError If p is not in [0,1] Examples -------- >>> G = nx.relaxed_caveman_graph(2, 3, 0.1, seed=42) References ---------- .. [1] Santo Fortunato, Community Detection in Graphs, Physics Reports Volume 486, Issues 3-5, February 2010, Pages 75-174. https://arxiv.org/abs/0906.0612 ) rrlistrrandomchoicehas_edger"r#) rrpseedrnodesuvxs rrr|sP AA GE 1 ;;=1  E"Azz!Q MM!Q  JJq!   Hrc ld|cxkrdksntjdd|cxkrdksntjdt|}t|Dcgc]}t|Dcgc]}|c}}}}t|D] }||||< t ||d||ddScc}wcc}}w) aReturns the random partition graph with a partition of sizes. A partition graph is a graph of communities with sizes defined by s in sizes. Nodes in the same group are connected with probability p_in and nodes of different groups are connected with probability p_out. Parameters ---------- sizes : list of ints Sizes of groups p_in : float probability of edges with in groups p_out : float probability of edges between groups directed : boolean optional, default=False Whether to create a directed graph seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. Returns ------- G : NetworkX Graph or DiGraph random partition graph of size sum(gs) Raises ------ NetworkXError If p_in or p_out is not in [0,1] Examples -------- >>> G = nx.random_partition_graph([10, 10, 10], 0.25, 0.01) >>> len(G) 30 >>> partition = G.graph["partition"] >>> len(partition) 3 Notes ----- This is a generalization of the planted-l-partition described in [1]_. It allows for the creation of groups of any size. The partition is store as a graph attribute 'partition'. References ---------- .. [1] Santo Fortunato 'Community Detection in Graphs' Physical Reports Volume 486, Issue 3-5 p. 75-174. https://arxiv.org/abs/0906.0612 gg?zp_in must be in [0,1]zp_out must be in [0,1]NFT)nodelistr+directed selfloopssparse)rr!lenrr ) sizesp_inp_outr+r2 num_blocksrsr*s rrrsr $ # 677 % 3 788UJ5::5FGz* +A% +GAG : !Q "     ,GsB00 B+ 9B0+B0c*t|g|z||||S)aReturns the planted l-partition graph. This model partitions a graph with n=l*k vertices in l groups with k vertices each. Vertices of the same group are linked with a probability p_in, and vertices of different groups are linked with probability p_out. Parameters ---------- l : int Number of groups k : int Number of vertices in each group p_in : float probability of connecting vertices within a group p_out : float probability of connected vertices between groups seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. directed : bool,optional (default=False) If True return a directed graph Returns ------- G : NetworkX Graph or DiGraph planted l-partition graph Raises ------ NetworkXError If `p_in`, `p_out` are not in `[0, 1]` Examples -------- >>> G = nx.planted_partition_graph(4, 3, 0.5, 0.1, seed=42) See Also -------- random_partition_model References ---------- .. [1] A. Condon, R.M. Karp, Algorithms for graph partitioning on the planted partition model, Random Struct. Algor. 18 (2001) 116-140. .. [2] Santo Fortunato 'Community Detection in Graphs' Physical Reports Volume 486, Issue 3-5 p. 75-174. https://arxiv.org/abs/0906.0612 r+r2)r)rrr7r8r+r2s rrrsj "1#'4TH UUrc||kDrtjdd}g} t|j|||z dz} | dkr(|| z|k\r|j ||z n|| z }|j | [t |||||S)aGenerate a Gaussian random partition graph. A Gaussian random partition graph is created by creating k partitions each with a size drawn from a normal distribution with mean s and variance s/v. Nodes are connected within clusters with probability p_in and between clusters with probability p_out[1] Parameters ---------- n : int Number of nodes in the graph s : float Mean cluster size v : float Shape parameter. The variance of cluster size distribution is s/v. p_in : float Probability of intra cluster connection. p_out : float Probability of inter cluster connection. directed : boolean, optional default=False Whether to create a directed graph or not seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. Returns ------- G : NetworkX Graph or DiGraph gaussian random partition graph Raises ------ NetworkXError If s is > n If p_in or p_out is not in [0,1] Notes ----- Note the number of partitions is dependent on s,v and n, and that the last partition may be considerably smaller, as it is sized to simply fill out the nodes [1] See Also -------- random_partition_graph Examples -------- >>> G = nx.gaussian_random_partition_graph(100, 10, 10, 0.25, 0.1) >>> len(G) 100 References ---------- .. [1] Ulrik Brandes, Marco Gaertler, Dorothea Wagner, Experiments on Graph Clustering Algorithms, In the proceedings of the 11th Europ. Symp. Algorithms, 2003. zs must be <= nrg?rr>)rr!intgaussappendr) nr;r.r7r8r2r+assignedr6sizes rr r 7sz 1u/00H E 4::aQ-. !8  d?a  LLX & D T  "%u4( SSrcr|dkrtjd|dkrtjdtj}t|D]`}t j t||z||z|zd}|j ||j||zdz|dz|z||zzb|S)acDefines a "ring of cliques" graph. A ring of cliques graph is consisting of cliques, connected through single links. Each clique is a complete graph. Parameters ---------- num_cliques : int Number of cliques clique_size : int Size of cliques Returns ------- G : NetworkX Graph ring of cliques graph Raises ------ NetworkXError If the number of cliques is lower than 2 or if the size of cliques is smaller than 2. Examples -------- >>> G = nx.ring_of_cliques(8, 4) See Also -------- connected_caveman_graph Notes ----- The `connected_caveman_graph` graph removes a link from each clique to connect it with the next clique. Instead, the `ring_of_cliques` graph simply adds the link without removing any link from the cliques. rz0A ring of cliques must have at least two cliques(The cliques must have at least two nodesr)rr!Graphrrrrr#) num_cliques clique_sizerirs rr r sNQQRRQIJJ  A ;  && !k/1{?[#@ A1   Oa !a%;!6+ :S!T   Hrc x|dkrd}tj|dkrtjdtjtjtj gfdt |dz D}|jdt |jD|S)a+Generate a windmill graph. A windmill graph is a graph of `n` cliques each of size `k` that are all joined at one node. It can be thought of as taking a disjoint union of `n` cliques of size `k`, selecting one point from each, and contracting all of the selected points. Alternatively, one could generate `n` cliques of size `k-1` and one node that is connected to all other nodes in the graph. Parameters ---------- n : int Number of cliques k : int Size of cliques Returns ------- G : NetworkX Graph windmill graph with n cliques of size k Raises ------ NetworkXError If the number of cliques is less than two If the size of the cliques are less than two Examples -------- >>> G = nx.windmill_graph(4, 5) Notes ----- The node labeled `0` will be the node connected to all other nodes. Note that windmill graphs are usually denoted `Wd(k,n)`, so the parameters are in the opposite order as the parameters of this method. rz/A windmill graph must have at least two cliquesrHc3NK|]}tjdz yw)rN)rcomplete_graph).0_rs r z!windmill_graph..s $T!R%6%6q1u%=$Ts"%rc3$K|]}d|f yw)rN)rPrLs rrRz!windmill_graph..sCaVCs) rr!disjoint_union_allrchainrOrrnumber_of_nodes)rDrmsgrs ` rr r sL 1u?s##1uIJJ    q ! "$TuQQRU|$T  A CU1a.?.?.A%BCC Hrc 6 t|t|k7rtjd|D].}t|t|k7stjd|srt|Dcgc] }t |} }t|| D]E}t|d|dD].} t | d| dz dkDstjdG|D](}|D]!} | dks| dkDstjd*|at|t |k7rtjd t|tt|k7r)tjd tt |}tt|} |r+tj} tj| | }n*tj} tj| d }tt|dzDcgc]}t |d|}}tt|dz Dcgc]}t|||||dzc}| jd <t| jd D]\}}|D]}| j!|| !d| _| jd }|D]\}} || k(r|r9|rtj||||}n[tj$||d }nAtj&||d }|r&tj(|t||||}|D]+}|j+||| ks| j,|-ntj|||| }|r||| dk(r|D]}| j,|||| dkDs t/j0|j+}t/j2|t/j0d||| z z }t5tj6|||dt5|}| j,||D]+}|j+||| ks| j,|-| Scc}wcc}wcc}w#t8$rYwxYw)a Returns a stochastic block model graph. This model partitions the nodes in blocks of arbitrary sizes, and places edges between pairs of nodes independently, with a probability that depends on the blocks. Parameters ---------- sizes : list of ints Sizes of blocks p : list of list of floats Element (r,s) gives the density of edges going from the nodes of group r to nodes of group s. p must match the number of groups (len(sizes) == len(p)), and it must be symmetric if the graph is undirected. nodelist : list, optional The block tags are assigned according to the node identifiers in nodelist. If nodelist is None, then the ordering is the range [0,sum(sizes)-1]. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. directed : boolean optional, default=False Whether to create a directed graph or not. selfloops : boolean optional, default=False Whether to include self-loops or not. sparse: boolean optional, default=True Use the sparse heuristic to speed up the generator. Returns ------- g : NetworkX Graph or DiGraph Stochastic block model graph of size sum(sizes) Raises ------ NetworkXError If probabilities are not in [0,1]. If the probability matrix is not square (directed case). If the probability matrix is not symmetric (undirected case). If the sizes list does not match nodelist or the probability matrix. If nodelist contains duplicate. Examples -------- >>> sizes = [75, 75, 300] >>> probs = [[0.25, 0.05, 0.02], [0.05, 0.35, 0.07], [0.02, 0.07, 0.40]] >>> g = nx.stochastic_block_model(sizes, probs, seed=0) >>> len(g) 450 >>> H = nx.quotient_graph(g, g.graph["partition"], relabel=True) >>> for v in H.nodes(data=True): ... print(round(v[1]["density"], 3)) 0.245 0.348 0.405 >>> for v in H.edges(data=True): ... print(round(1.0 * v[2]["weight"] / (sizes[v[0]] * sizes[v[1]]), 3)) 0.051 0.022 0.07 See Also -------- random_partition_graph planted_partition_graph gaussian_random_partition_graph gnp_random_graph References ---------- .. [1] Holland, P. W., Laskey, K. B., & Leinhardt, S., "Stochastic blockmodels: First steps", Social networks, 5(2), 109-137, 1983. z'sizes' and 'p' do not match.z'p' must be a square matrix.rrg:0yE>z'p' must be symmetric.zEntries of 'p' not in [0,1].Nz$'nodelist' and 'sizes' do not match.znodelist contains duplicate.r partition)blockr )r5rNetworkXExceptionzipr&abssumsetrDiGraphrproductrIcombinations_with_replacementgraph enumerateadd_nodename permutationsrrVr'r#mathlogfloornextislice StopIteration)r6r*r1r+r2r3r4rowrL p_transposejprob block_rangeg block_iterr/ size_cumsumblock_idr,nodepartsrelograndskips rr r sb 5zSV""#BCCG q6SX &&'EF FG (+Q01tAw0 0Q $ IA1qt_ Iqtad{#e+../GHH I I K KDax4!8**+IJJ KK  x=CJ &&&'MN N x=CH . .&&'EF FU$E #K JJL&&{K@ HHJ<<[!L ,1#e*q.,ABq3uQqz?BKBs;'!+,  H[^k!a%&8 9:AGGK %QWW[%9:-% -D JJt8J , --&AF GGK E"#1 6%--eAhaAE%2258Q?E!..uQx;%OOE3uQxq3JKE #;;=1Q47*AJJN #%%eAha9E tAw!|#AAJJN#1a1"&((4;;="9#zz'DHHQ1a[4I*IJY--eT4@$G K" A #;;=1Q47*AJJN #A"#F H[18CT)s%,Q<<R,R4BR  RRctjj|||}||kDr'tjj|||}||kDr'|S)zReturns a random value chosen from the bounded Zipf distribution. Repeatedly draws values from the Zipf distribution until the threshold is met, then returns that value. )rutilszipf_rv)gammaxmin thresholdr+results r_zipf_rv_belowrsK XX  eT4 0F 9 !!%t4 9  Mrc t|D]>}g}||s&|jt||||||s&||s<|cStjd)aReturns a list of numbers obeying a constrained power law distribution. ``gamma`` and ``low`` are the parameters for the Zipf distribution. ``high`` is the maximum allowed value for values draw from the Zipf distribution. For more information, see :func:`_zipf_rv_below`. ``condition`` and ``length`` are Boolean-valued functions on lists. While generating the list, random values are drawn and appended to the list until ``length`` is satisfied by the created list. Once ``condition`` is satisfied, the sequence generated in this way is returned. ``max_iters`` indicates the number of times to generate a list satisfying ``length``. If the number of iterations exceeds this value, :exc:`~networkx.exception.ExceededMaxIterations` is raised. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. z#Could not create power law sequence)rrCrrExceededMaxIterations) rlowhigh conditionlength max_itersr+rLseqs r_powerlaw_sequencersd,9 + JJ~eS$= >+ S>J  " "#H IIrcd}td }d}t||z |kDr'|}|d||z|zz z }|dz }t||z |kDr'|S)aThe Hurwitz zeta function, or the Riemann zeta function of two arguments. ``x`` must be greater than one and ``q`` must be positive. This function repeatedly computes subsequent partial sums until convergence, as decided by ``tolerance``. rinfr)floatr^)r/q tolerancezz_prevrs r _hurwitz_zetarsg AEl]F A a&j/I % Q1q5Q,  Q a&j/I % Hrc ddlm}|}d}||z dz |z}d} d} t| |z kDr| |kDrt j dd} t t||dzD]} | | | dzz|||z z } | |kDr|}||z dz |z}n |}||z dz |z}| dz } t| |z kDrt|S#t$rfd}YwxYw)z7Returns a minimum degree from the given average degree.r)zetact||SN)r)r/rrs rrz"_generate_min_degree..zetas Ay1 1rrrzCould not match average_degree) scipy.specialr ImportErrorr^rrrrAround) raverage_degree max_degreerrr min_deg_top min_deg_bot min_deg_miditrs mid_avg_degr/s ` r_generate_min_degreers"2& KK,1K?K DK kN* +i 7 ) **+KL L s;'a8 JA A5&1*-e[1II IK J  '%K&49KGK%K&49KGK   kN* +i 7  1 2 22sB>>CCc(|Dcgc] }t}}t|}tt|}t|D]} |j } |j tt|} t || d|z z} | || kr|| j| n|j| t|| || kDr"|j|| j |r|cSd} tj| cc}w)aReturns a list of sets, each of which represents a community. ``degree_seq`` is the degree sequence that must be met by the graph. ``community_sizes`` is the community size distribution that must be met by the generated list of sets. ``mu`` is a float in the interval [0, 1] indicating the fraction of intra-community edges incident to each node. ``max_iters`` is the number of times to try to add a node to a community. This must be greater than the length of ``degree_seq``, otherwise this function will always fail. If the number of iterations exceeds this value, :exc:`~networkx.exception.ExceededMaxIterations` is raised. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. The communities returned by this are sets of integers in the set {0, ..., *n* - 1}, where *n* is the length of ``degree_seq``. rz:Could not assign communities; try increasing min_community) r`r5r&rpopr(raddrCrr) degree_seqcommunity_sizesmurr+rQrrDfreerLr.cr;rXs r_generate_communitiesrs6- -ce -F - JA a>D 9  HHJ KKc/23 4 *Q-1r6* + q! ! 1IMM!  KKN vay>OA. . KKq  (M!" GC " "3 ''+.sD c |dkDstjd|dkDstjdd|cxkrdksntjd|}n"d|cxkrksntjd|du|duz stjd|t|||| | }||} } d }fd }t|| | ||| | }| t |}| t |}||} } fd }fd }t|| | ||| | }| d zz} t |||| | }tj}|jt|D]}|D]}|j|t||d|z zkrS| jt|}|j|||j|t||d|z zkrS|j|||krH| jt}||vr|j|||j|||krH||j|d<|S)aReturns the LFR benchmark graph. This algorithm proceeds as follows: 1) Find a degree sequence with a power law distribution, and minimum value ``min_degree``, which has approximate average degree ``average_degree``. This is accomplished by either a) specifying ``min_degree`` and not ``average_degree``, b) specifying ``average_degree`` and not ``min_degree``, in which case a suitable minimum degree will be found. ``max_degree`` can also be specified, otherwise it will be set to ``n``. Each node *u* will have $\mu \mathrm{deg}(u)$ edges joining it to nodes in communities other than its own and $(1 - \mu) \mathrm{deg}(u)$ edges joining it to nodes in its own community. 2) Generate community sizes according to a power law distribution with exponent ``tau2``. If ``min_community`` and ``max_community`` are not specified they will be selected to be ``min_degree`` and ``max_degree``, respectively. Community sizes are generated until the sum of their sizes equals ``n``. 3) Each node will be randomly assigned a community with the condition that the community is large enough for the node's intra-community degree, $(1 - \mu) \mathrm{deg}(u)$ as described in step 2. If a community grows too large, a random node will be selected for reassignment to a new community, until all nodes have been assigned a community. 4) Each node *u* then adds $(1 - \mu) \mathrm{deg}(u)$ intra-community edges and $\mu \mathrm{deg}(u)$ inter-community edges. Parameters ---------- n : int Number of nodes in the created graph. tau1 : float Power law exponent for the degree distribution of the created graph. This value must be strictly greater than one. tau2 : float Power law exponent for the community size distribution in the created graph. This value must be strictly greater than one. mu : float Fraction of inter-community edges incident to each node. This value must be in the interval [0, 1]. average_degree : float Desired average degree of nodes in the created graph. This value must be in the interval [0, *n*]. Exactly one of this and ``min_degree`` must be specified, otherwise a :exc:`NetworkXError` is raised. min_degree : int Minimum degree of nodes in the created graph. This value must be in the interval [0, *n*]. Exactly one of this and ``average_degree`` must be specified, otherwise a :exc:`NetworkXError` is raised. max_degree : int Maximum degree of nodes in the created graph. If not specified, this is set to ``n``, the total number of nodes in the graph. min_community : int Minimum size of communities in the graph. If not specified, this is set to ``min_degree``. max_community : int Maximum size of communities in the graph. If not specified, this is set to ``n``, the total number of nodes in the graph. tol : float Tolerance when comparing floats, specifically when comparing average degree values. max_iters : int Maximum number of iterations to try to create the community sizes, degree distribution, and community affiliations. seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness`. Returns ------- G : NetworkX graph The LFR benchmark graph generated according to the specified parameters. Each node in the graph has a node attribute ``'community'`` that stores the community (that is, the set of nodes) that includes it. Raises ------ NetworkXError If any of the parameters do not meet their upper and lower bounds: - ``tau1`` and ``tau2`` must be strictly greater than 1. - ``mu`` must be in [0, 1]. - ``max_degree`` must be in {1, ..., *n*}. - ``min_community`` and ``max_community`` must be in {0, ..., *n*}. If not exactly one of ``average_degree`` and ``min_degree`` is specified. If ``min_degree`` is not specified and a suitable ``min_degree`` cannot be found. ExceededMaxIterations If a valid degree sequence cannot be created within ``max_iters`` number of iterations. If a valid set of community sizes cannot be created within ``max_iters`` number of iterations. If a valid community assignment cannot be created within ``10 * n * max_iters`` number of iterations. Examples -------- Basic usage:: >>> from networkx.generators.community import LFR_benchmark_graph >>> n = 250 >>> tau1 = 3 >>> tau2 = 1.5 >>> mu = 0.1 >>> G = LFR_benchmark_graph( ... n, tau1, tau2, mu, average_degree=5, min_community=20, seed=10 ... ) Continuing the example above, you can get the communities from the node attributes of the graph:: >>> communities = {frozenset(G.nodes[v]["community"]) for v in G} Notes ----- This algorithm differs slightly from the original way it was presented in [1]. 1) Rather than connecting the graph via a configuration model then rewiring to match the intra-community and inter-community degrees, we do this wiring explicitly at the end, which should be equivalent. 2) The code posted on the author's website [2] calculates the random power law distributed variables and their average using continuous approximations, whereas we use the discrete distributions here as both degree and community size are discrete. Though the authors describe the algorithm as quite robust, testing during development indicates that a somewhat narrower parameter set is likely to successfully produce a graph. Some suggestions have been provided in the event of exceptions. References ---------- .. [1] "Benchmark graphs for testing community detection algorithms", Andrea Lancichinetti, Santo Fortunato, and Filippo Radicchi, Phys. Rev. E 78, 046110 2008 .. [2] https://www.santofortunato.net/resources rztau1 must be greater than oneztau2 must be greater than onerz!mu must be in the interval [0, 1]Nz)max_degree must be in the interval (0, n]z8Must assign exactly one of min_degree and average_degreec$t|dzdk(S)Nrrr_)rs rrz&LFR_benchmark_graph..conditions3x!|q  rc t|k\Sr)r5rrDs rrz#LFR_benchmark_graph..length3x1}rc t|k(Srrrs rrz&LFR_benchmark_graph..conditionrrc t|k\Srrrs rrz#LFR_benchmark_graph..lengthrr community)rr!rrminmaxrrIadd_nodes_fromrdegreerr(r&r#r,)rDtau1tau2rr min_degreer min_community max_communitytolrr+rrrrdeg_seqcomms communitiesrrr-r.s` rr r )str !8>?? !8>?? iN)__doc__rrinetworkxrnetworkx.utilsr__all__ _dispatchablerrrrrr r r r rrrrrr rTrrrsH * T2+ 3+ \T22 32 jT2/ 3/ dT2J3JZT23V33VlT2HT3HTVT24 34 nT21 31 hT2PTc 3c L J> $@0(fT2  C 3C r