+
    �°³jt{  ã                   ó<  € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RI	H
t
Ht ^ RIHtHt RR.t]! R4      ]P                   ! RR	7      RRR
RRRRRRRRR/R l4       4       t]! R4      ]P                   ! RR	7      RRRRR
RRRRR/R l4       4       tR tR tR tR# )zGDetecting communities based on the Leiden Community Detection algorithmN)Údeque)Úconstant_potts_modelÚ
modularity)Únot_implemented_forÚpy_random_stateÚleiden_communitiesÚleiden_partitionsÚseedÚweight)Ú
edge_attrsÚ
resolutiong      ð?Ú	max_levelÚmetricÚcpmÚthetag{®Gáz„?c          	     ó°   € \        WW$WVR7      pVe)   V^ 8:  d   \        R4      h\        P                  ! Ws4      p\	        V^R7      pVP                  4       # )a5  Return best node communities of `G`.

This function uses the Leiden Community Detection algorithm [1]_ to estimate
the community structure based on metric optimization. The metric can be
modularity or Constant Potts Model (CPM). Leiden ensures that the communities
are well connected whereas Louvain does not.
The functions which compute those two metrics are
:func:`~networkx.algorithms.community.quality.modularity` and
:any:`constant_potts_model`

The algorithm works in 3 phases. In the first phase, starting with a partition
of all singleton nodes, and a randomly shuffled queue of all nodes, each node
in the queue is considered in order and moved to the current community which
most increases the metric value. The node can stay in its current community.
If it moves, all neighbors of the moved node which are not currently in the
queue are added to the end of the queue to be considered for moving in turn.
The first phase continues until the queue is empty, resulting in a node
partition $P$.

The second phase refines $P$ to obtain $P_{refined}$. Each community in $P$
is considered on its own and split into subcommunities using a method closely
resembling the first phase. Starting from a subpartition of singleton nodes,
and a randomly ordered queue, subcommunities are merged only if both are
sufficiently well connected. This is determined randomly using a distribution
based on edge weights and controlled by the parameter `theta`. The merging
results in a splitting or refinement of the communities in $P$ such that
each set in $P_{refined}$ is a subset of one community in $P$. Thus each
community in $P$ also represents a community of subcommunities from $P_{refined}$.

The third phase involves creating an aggregate network of community connections.
The communities in $P_{refined}$ act as nodes in the new network. Edges exist
between communities that have underlying nodes connected to nodes in the other
community. The weight of each such edge is the sum of the original graph edge
weights for edges between nodes in the two partitions. An initial partition of
the new network is provided via $P$ by joining the subcommunities of each
community in $P$ into an aggregated community of the new network. Each
subcommunity from $P_{refined}$ is a subset of one community in $P$ and thus
belongs to one community in the new network.

The result of the 3 phases is a new network (level of aggregation) which encodes
a new partition of the original network. We can reapply the 3 phases
to create bigger aggregations with increased metric value. At each level
the network is smaller with fewer nodes and edges, so convergence is guaranteed.
The three phases are repeatedly applied until no gain is achieved or
`max_level` applications have been performed.

Parameters
----------
G : NetworkX graph
weight : string or None, optional (default="weight")
    The name of an edge attribute that holds the numerical value
    used as a weight. If None then each edge has weight 1.
metric : {"cpm", "modularity"}, default="cpm"
    The name of the partition quality metric that the algorithm optimises.
    Allowed names are "cpm" and "modularity" for constant potts model and
    modularity respectively. See functions
    :func:`~networkx.algorithms.community.quality.modularity` and
    :any:`constant_potts_model` for more info.
resolution : float, optional (default=1)
    Resolution should be a positive number indicating the coarseness of
    the communities produced. With a lower resolution, larger communities
    are produced. To see the smaller sub-communities, use a higher resolution.
max_level : int or None, optional (default=None)
    The maximum number of levels (steps of the algorithm) to compute.
    Must be a positive integer or None indicating the process is reapplied
    until no increase in metric is obtained.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
theta : float (default=0.01)
    Parameter that determines the degree of randomness in the second phase
    _refine_partition step of the algorithm,

Returns
-------
list of sets of nodes
    A partition of `G` as a list of disjoint sets of nodes. Each set represents
    one community of nodes and each node of `G` appears in exactly one set.

Examples
--------
>>> G = nx.barbell_graph(3, 4)
>>> cpm_comm = nx.community.leiden_communities(G, resolution=0.2, seed=62537113)
>>> len(cpm_comm)
3
>>> sorted(sorted(c) for c in cpm_comm)
[[0, 1, 2], [3, 4, 5, 6], [7, 8, 9]]

Higher resolution produces smaller sub-communities:

>>> cpm_comm = nx.community.leiden_communities(G, resolution=0.4, seed=62537114)
>>> len(cpm_comm)
4
>>> sorted(sorted(c) for c in cpm_comm)
[[0, 1, 2], [3, 4], [5, 6], [7, 8, 9]]

Notes
-----
The order in which the nodes are considered can affect the final output.
In the algorithm the ordering happens using a random shuffle controlled by
`seed` which also controls the randomness involved in selecting communities
to merge during the refining (2nd) stage.

References
----------
.. [1] Traag, V.A., Waltman, L. & van Eck, N.J.
   From Louvain to Leiden: guaranteeing well-connected communities.
   Sci Rep 9, 5233 (2019).
   https://doi.org/10.1038/s41598-019-41695-z

See Also
--------
leiden_partitions
:any:`louvain_communities`
:func:`networkx.algorithms.community.quality.modularity`
:any:`constant_potts_model`
)r
   r   r	   r   r   z5max_level argument must be a positive integer or None)Úmaxlen)r   Ú
ValueErrorÚ	itertoolsÚislicer   Úpop)	ÚGr
   r   r   r	   r   r   Ú
partitionsÚfinal_partitions	   &$$$$$$  Úe/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/community/leiden.pyr   r      s\   € ôD #Ø	 ZÀ6ô€Jð ÒØ˜Œ>ÜÐTÓUÐUÜ×%Ò% jÓ<ˆ
Ü˜J¨qÔ1€OØ×ÑÓ Ð ó    c             #  ó  aa'a(a)a*a+a,a-a."  € V  Uu. uF  qf0NK  	  pp\         P                  ! V 4      '       d   Vx € R# T pVP                  4       p	V	'       d   \         P                  ! 4       M\         P                  ! 4       p V P                  V4       VP                  4       '       dm   VP                  V^R7       FT  w  rjpV P                  Wj4      '       d%   W,          V
,          R;;,          V,          uu&   KA  V P                  WjVR7       KV  	  M"V P                  VP                  V^R7      4       V P                  P                  4        UUU
Uu/ uF8  w  rlYlP                  4        U
Uu/ uF  w  r­Wj8w  g   K  W­R,          bK  	  upp
bK:  	  upp
ppo)V	'       d|   V P                  P                  4        F]  w  r¬S)V
,          pVP                  4        F;  w  rmWj8X  d   K  Wn9   d   Wæ;;,          VR,          ,          uu&   K0  VR,          Wæ&   K=  	  K_  	  S)V P                  R&   \         P                  ! Y Uu/ uF  qÿV0bK  	  upR4       VR8X  d`   \         P"                  ! \$        SRRR	7      p\&        P)                  V ^4      o,RS,/pV	'       d   ^S,          o*V)V*V,3R
 lpEM0So*V)V*V,3R lpEM$VR8X  dÚ   \         P"                  ! \*        SRR7      pV	'       dj   \'        V P-                  RR7      4      o+\'        V P/                  RR7      4      o-RS+RS-/p\1        S-P3                  4       4      pSV,          o*V)V*V+V-3R lpEM�\'        V P5                  RR7      4      o(RS(/p\1        S(P3                  4       4      pSV,          o*V(V)V*3R lpEMDVR8X  Ed$   V	'       d   \         P6                  ! R4      hR pTpV P9                  RR7       UUu0 uF  w  ppV^ 8X  g   K  VkK  	  pppV P9                  RR7       UUu0 uF  w  ppV^8X  g   K  VkK  	  ppp\'        V P5                  RR7      4      o(V Uu/ uF  qfS(V,          bK  	  upo.S.P;                  R V 4       4       V Uu/ uF  qfS(V,          bK  	  upo'S'P;                  R V 4       4       RS.RS'/pV'V)V.V3R lp\         P6                  ! R4      h\         P6                  ! RV 24      hV! W4      pRp\=        V 4       UUu/ uF	  w  ppVVbK  	  pppV'       Ed3   \?        V VVVR 7      pV Uu. uF  p\A        V VVWE4      NK  	  p pV  U!U"u. uF  p!V! F  p"V"NK  	  K  	  p#p!p"V! V V#4      p$V$V,
          R!8„  pT$p\C        V V V4      w  p pV P9                  RR7       U%U&u. uF  w  p%p&V&PE                  4       NK  	  up&p%x € V P                  R,          o)VR8X  d$   VR,          o,\         P                  ! V S,R4       Kì  VR8X  d*   V	'       d   VR,          o+VR,          o-EK  VR,          o(EK  VR8X  g   EK&  VR,          o.VR,          o'EK;  R# u upi u upp
i u upp
ppi u upi u uppi u uppi u upi u upi u uppi u upi u up"p!i u up&p%i 5i)"aV  Yield partitions at each level of Leiden Community Detection

Leiden Community Detection is an algorithm to extract the community
structure of a network based on modularity optimization.

The partitions across levels (steps of the algorithm) form a dendrogram
of communities. A dendrogram is a diagram representing a tree and each
level represents a partition of the graph `G`. The top level contains the
smallest communities and as you traverse the tree the communities get
bigger and the overall partition quality metric increases.

Each level is generated by executing the three phases of the
`Leiden Community Detection algorithm <leiden_communities>`.

Parameters
----------
G : NetworkX graph
weight : string or None, optional (default="weight")
    The name of an edge attribute that holds the numerical value
    used as a weight. If None then each edge has weight 1.
metric : {"cpm", "modularity"}, default="cpm"
    The name of the partition quality metric that the algorithm optimises.
    Allowed names are "cpm" and "modularity".
resolution : float, optional (default=1)
    Resolution should be a positive number indicating the coarseness of
    the communities produced. With a lower resolution, larger communities
    are produced. To see the smaller sub-communities, use a higher resolution.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
theta : float (default=0.01)
    Parameter that determines the degree of randomness in the second phase
    _refine_partition step of the algorithm,

Yields
------
list of sets of nodes
    A partition of `G` as a list of disjoint sets of nodes. Each set represents
    one community of nodes and each node of `G` appears in exactly one set.
    The quality metric is nondecreasing across the yielded partitions.

References
----------
.. [1] Traag, V.A., Waltman, L. & van Eck, N.J.
   From Louvain to Leiden: guaranteeing well-connected communities.
   Sci Rep 9, 5233 (2019).
   https://doi.org/10.1038/s41598-019-41695-z

See Also
--------
leiden_communities
:any:`louvain_partitions`
N)ÚdataÚdefaultr
   ©r
   Úedge_wtsÚnodesr   Únode_weight)r   r"   r
   c                 ób  <aa€ S'       g   ^ # \        V \        4      '       df   \        V3R lV  4       4      p\        V3R lS 4       4      p\        V 4      \        S4      8:  d   T SupoMSV upo\        VV	3R lV 4       4      pM‘T pSV,          p\        S4      ^8X  d8   \	        \        S4      4      pSV,          pS	V,          P                  V^ 4      pM?\        V3R lS 4       4      p\        V3R lS	V,          P                  4        4       4      pVS
V,          V,          ,
          # )é    c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5i©N© ©Ú.0ÚuÚnode_weightss   & €r   Ú	<genexpr>Ú8leiden_partitions.<locals>.delta_func.<locals>.<genexpr>0  ó   øé € Ð$K¹l¸ \°!§_¢_»lùó   ƒc              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r(   s   & €r   r,   r-   1  ó   øé € Ð#G¹Y¸ L°§O¢O»Yùr/   c              3   óz   <"  € T F0  pSV,          P                  4        F  w  r#VS9   g   K  Vx € K  	  K2  	  R # 5ir&   ©Úitems©r)   r*   ÚvÚwtÚCr    s   &   €€r   r,   r-   7  ó2   øé € ÐU© 1°xÀµ{×7HÑ7HÖ7J©e¨aÈaÐSTÉfŸBšBÑ7J™B«ùó   ƒ%;­;c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r(   s   & €r   r,   r-   @  ó   øé € Ð'KÁ¸A¨°Q¯ªÃùr/   c              3   ó>   <"  € T F  w  rVS9   g   K  Vx € K  	  R # 5ir&   r'   ©r)   r6   r7   Ú	communitys   &  €r   r,   r-   A  ó   øé € ÐVÑ0C¡u qÀqÈIÁ~§¢Ó0Cùó   ƒ“
©Ú
isinstanceÚsetÚsumÚlenÚnextÚiterÚgetr4   ©Únodes_to_addr?   Ú
nodes_sizeÚ	comm_sizeÚAÚEr*   r6   r8   r    Úgammar+   s   &f      @€€€r   Ú
delta_funcÚ%leiden_partitions.<locals>.delta_func,  óô   ú€ ß ÙÜ˜l¬C×0Ò0Ü!$Ô$K¹lÓ$KÓ!K�JÜ #Ô#G¹YÓ#GÓ G�Iä˜<Ó(¬C°	«NÔ:Ø+¨Y˜˜™1à(¨,˜˜˜1ÜÕU©ÓUÓU‘Aà$�AØ!-¨a¥�JÜ˜9“~¨Ô*Ü ¤ i£Ó1˜Ø$0°¥O˜	Ø$ Q�KŸO™O¨A¨qÓ1™ä$'Ô'KÁÓ'KÓ$K˜	ÜÔV°¸µ×0AÑ0AÔ0CÓVÓV˜à˜5 9Õ,¨zÕ9Õ9Ð9r   c                 ób  <aa€ S'       g   ^ # \        V \        4      '       df   \        V3R lV  4       4      p\        V3R lS 4       4      p\        V 4      \        S4      8:  d   T SupoMSV upo\        VV	3R lV 4       4      pM‘T pSV,          p\        S4      ^8X  d8   \	        \        S4      4      pSV,          pS	V,          P                  V^ 4      pM?\        V3R lS 4       4      p\        V3R lS	V,          P                  4        4       4      pVS
V,          V,          ,
          # )r$   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r(   s   & €r   r,   r-   Q  r.   r/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r(   s   & €r   r,   r-   R  r1   r/   c              3   óz   <"  € T F0  pSV,          P                  4        F  w  r#VS9   g   K  Vx € K  	  K2  	  R # 5ir&   r3   r5   s   &   €€r   r,   r-   X  r9   r:   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   )r)   r6   r+   s   & €r   r,   r-   a  r<   r/   c              3   ó>   <"  € T F  w  rVS9   g   K  Vx € K  	  R # 5ir&   r'   r>   s   &  €r   r,   r-   b  r@   rA   rB   rJ   s   &f      @€€€r   rQ   rR   M  rS   r   r   )r   r
   Ú	in_degreeÚ
out_degreec                 ó  <aa
€ S'       g   ^ # \        V \        4      '       d�   \        V 4      \        S4      8:  d   T Supo
MSV upo
\        V3R lV 4       4      p\        V3R lV 4       4      p\        V3R lS
 4       4      p\        V3R lS
 4       4      p\        V
V3R lV 4       4      pM¸T pSV,          pSV,          p\        S4      ^8X  dA   \	        \        S4      4      p	SV	,          pSV	,          pSV,          P                  V	^ 4      pMT\        V3R lS 4       4      p\        V3R lS 4       4      p\        V3R lSV,          P                  4        4       4      pVSW6,          WE,          ,           ,          ,
          # )	r$   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   ©r)   r*   Ú
in_degreess   & €r   r,   r-   …  ó   øé € Ð8±a°˜z¨!Ÿ}š}³aùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   ©r)   r*   Úout_degreess   & €r   r,   r-   †  ó   øé € Ð:¹°1 ¨A§¢»ùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r^   s   & €r   r,   r-   ‡  r`   r/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   rb   s   & €r   r,   r-   ˆ  rd   r/   c              3   óz   <"  € T F0  pSV,          P                  4        F  w  r#VS9   g   K  Vx € K  	  K2  	  R # 5ir&   r3   r5   s   &   €€r   r,   r-   Š  r9   r:   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r^   s   & €r   r,   r-   •  s   øé € Ð"D¹)°Q :¨a§=¢=»)ùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   rb   s   & €r   r,   r-   –  s   øé € Ð#F¹I°q K°§N¢N»Iùr/   c              3   ó>   <"  € T F  w  rVS9   g   K  Vx € K  	  R # 5ir&   r'   r>   s   &  €r   r,   r-   —  r@   rA   )rC   rD   rF   rE   rG   rH   rI   r4   )rK   r?   rN   ÚA_inÚA_outÚC_inÚC_outrO   r*   r6   r8   r    rP   r_   rc   s   &f        @€€€€r   rQ   rR   |  s<  ú€ ß ÙÜ˜l¬C×0Ò0Ü˜<Ó(¬C°	«NÔ:Ø+¨Y˜˜™1à(¨,˜˜˜1äÔ8±aÓ8Ó8�DÜÔ:¹Ó:Ó:�EÜÔ8±aÓ8Ó8�DÜÔ:¹Ó:Ó:�EäÕU©ÓUÓU‘Aà$�AØ% a�=�DØ'¨�N�EÜ˜9“~¨Ô*Ü ¤ i£Ó1˜Ø)¨!�}˜Ø +¨A¥˜Ø$ Q�KŸO™O¨A¨qÓ1™ä"Ô"D¹)Ó"DÓD˜Ü #Ô#F¹IÓ#FÓ F˜ÜÔV°¸µ×0AÑ0AÔ0CÓVÓV˜ð ˜5 D¥L°5µ<Õ$?Õ@Õ@Ð@r   Údegreec                 ób  <aa€ S'       g   ^ # \        V \        4      '       df   \        V	3R lS 4       4      p\        V	3R lV  4       4      p\        V 4      \        S4      8:  d   T SupoMSV upo\        VV
3R lV 4       4      pM‘T pS	V,          p\        S4      ^8X  d8   \	        \        S4      4      pS	V,          pS
V,          P                  V^ 4      pM?\        V	3R lS 4       4      p\        V3R lS
V,          P                  4        4       4      pVSV,          V,          ,
          # )r$   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   ©r)   r*   Údegreess   & €r   r,   r-   ¯  s   øé € Ð#B¹	°1 G¨A§J¢J»	ùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   rr   s   & €r   r,   r-   °  s   øé € Ð$F¹°A W¨Q§Z¢Z»ùr/   c              3   óz   <"  € T F0  pSV,          P                  4        F  w  r#VS9   g   K  Vx € K  	  K2  	  R # 5ir&   r3   r5   s   &   €€r   r,   r-   ¶  r9   r:   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   rr   s   & €r   r,   r-   ¿  s   øé € Ð'F¹I°q¨°¯
ª
»Iùr/   c              3   ó>   <"  € T F  w  rVS9   g   K  Vx € K  	  R # 5ir&   r'   r>   s   &  €r   r,   r-   À  r@   rA   rB   )rK   r?   rM   rL   rN   rO   r*   r6   r8   rs   r    rP   s   &f      @€€€r   rQ   rR   «  sö   ú€ ß ÙÜ˜l¬C×0Ò0Ü #Ô#B¹	Ó#BÓ B�IÜ!$Ô$F¹Ó$FÓ!F�Jä˜<Ó(¬C°	«NÔ:Ø+¨Y˜˜™1à(¨,˜˜˜1ÜÕU©ÓUÓU‘Aà$�AØ!(¨¥�JÜ˜9“~¨Ô*Ü ¤ i£Ó1˜Ø$+¨A¥J˜	Ø$ Q�KŸO™O¨A¨qÓ1™ä$'Ô'F¹IÓ'FÓ$F˜	ÜÔV°¸µ×0AÑ0AÔ0CÓVÓV˜ð ˜5 :Õ-°	Õ9Õ9Ð9r   Úbarber_modularityz-barber_modularity not implemented for DiGraphc                  ó   € R # r&   r'   r'   r   r   rx   Ú,leiden_partitions.<locals>.barber_modularityÔ  s   € Ùr   Ú	bipartite©r   c              3   ó(   "  € T F  q^ 3x € K
  	  R# 5i©r$   Nr'   ©r)   r*   s   & r   r,   Ú$leiden_partitions.<locals>.<genexpr>à  s   é € Ð6©: a˜q�6«:ùó   ‚c              3   ó(   "  € T F  q^ 3x € K
  	  R# 5ir~   r'   r   s   & r   r,   r€   â  s   é € Ð6©I q �F«Iùr�   Ú
red_degreeÚblue_degreec                 ó  <a	€ \        V3R  lV 4       4      p\        V
3R lV 4       4      p\        V \        4      '       dd   \        V3R lV  4       4      p\        V
3R lV  4       4      p\        V 4      \        V4      8:  d   Yupo	MYupo	\        V	V3R lV 4       4      pM@SV ,          pS
V ,          pYupo	\        V	3R lSV,          P	                  4        4       4      pVSWC,          WR,          ,           ,          ,
          # )c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   ©r)   r*   Úred_degreess   & €r   r,   r-   ì  s   øé € Ð=±9¨a˜; qŸ>š>³9ùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   ©r)   r*   Úblue_degreess   & €r   r,   r-   í  s   øé € Ð?±Y°˜L¨ŸOšO³Yùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   r‡   s   & €r   r,   r-   ï  s   øé € ÐE¹°1 ¨A§¢»ùr/   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir&   r'   rŠ   s   & €r   r,   r-   ð  s   øé € Ð G¹,°Q ¨a§¢»,ùr/   c              3   óz   <"  € T F0  pSV,          P                  4        F  w  r#VS9   g   K  Vx € K  	  K2  	  R # 5ir&   r3   r5   s   &   €€r   r,   r-   ö  s1   øé € ÐQ¡A˜q°8¸Aµ;×3DÑ3DÖ3F©%¨!È!ÈqÉ&ŸšÑ3F™£Aùr:   c              3   ó>   <"  € T F  w  rVS9   g   K  Vx € K  	  R # 5ir&   r'   )r)   r6   r7   r8   s   &  €r   r,   r-   ü  s   øé € ÐFÑ(;™u˜q¸qÀA¹vŸšÓ(;ùrA   )rE   rC   rD   rF   r4   )rK   r?   Úcomm_redÚ	comm_blueÚ	nodes_redÚ
nodes_bluerN   rO   r*   r8   r‹   r    rˆ   r   s   &&       @€€€€r   rQ   rR   ë  sØ   ù€ ÜÔ=±9Ó=Ó=ˆHÜÔ?±YÓ?Ó?ˆIÜ˜,¬×,Ò,ÜÔE¹ÓEÓE�	Ü Ô G¹,Ó GÓG�
ä�|Ó$¬¨I«Ô6Ø'�D�A‘qà$�D�A�qÜÕQ¡AÓQÓQ‘à'¨Õ5�	Ø)¨,Õ7�
à#���1ÜÔF¨°­×(9Ñ(9Ô(;ÓFÓF�à�z YÕ%:¸ZÕ=RÕ%RÕSÕSÐSr   z,barber_modularity not implemented for leidenz:leiden only supports metrics "cpm" and "modularity". Got: T)r	   gH¯¼šò×z>)#ÚnxÚis_emptyÚis_directedÚDiGraphÚGraphÚadd_nodes_fromÚis_multigraphÚedgesÚhas_edgeÚadd_edgeÚadd_weighted_edges_fromÚ_adjr4   Ú_predÚgraphÚset_node_attributesÚ	functoolsÚpartialr   ÚdictÚfromkeysr   rZ   r[   rE   Úvaluesro   ÚNetworkXErrorr!   ÚupdateÚ	enumerateÚ_move_nodes_fastÚ_merge_node_subsetÚ_create_aggregate_graphÚcopy)/r   r
   r   r   r	   r   r*   Ú	partitionÚorig_Gr–   r6   r7   ÚnbrsÚddÚv_wtsÚnÚmetric_functionÚnode_attributesrQ   ÚmÚtwo_mrx   ÚcÚ	red_nodesÚ
blue_nodesÚQÚimprovement_madeÚiÚnodeÚnode2comÚPr8   Ú	P_refinedÚpÚcommÚP_refined_flatÚQ_newÚ_r!   r‹   rs   r    rP   r_   r+   rc   rˆ   s/   &$$d$$                                 @@@@@@@@r   r   r   ž   sö  ÿøé € ñB  Ó ™a˜“™a€IÐ ä	‡{‚{�1‡~‚~ØŠÙð €FØ×$Ñ$Ó&€Kß#Œ�
Š
Œ¬¯ª«€AØ×Ñ�VÔà×Ñ×ÒØŸ™¨&¸!˜Ö<‰HˆA�"Ø�z‰z˜!×ÒØ•�Q•˜×! RÕ'Õ!à—
‘
˜1¨�
Ö+ò	 =ð 	
×!Ñ! &§,¡,°FÀA ,Ó"FÔGð
 —v‘v—|‘|”~öá%‰GˆAð 	
¯©¬Ô@©¡ ¸¹ŒOˆA�(�|ŠO©Ò@Ò@Ù%ô€H÷
 ð
 —w‘w—}‘}–‰GˆAØ˜Q•KˆEØŸ™ž‘�Ø”6ÙØ”:Ø—H  8¥Õ,•Hà! (�|�E“Hó &ñ 'ð #€A‡G�GˆJÑô ×Ò˜1¨vÓ6©v¨! 1 #šv©vÑ6¸Ô@à�„ä#×+Ò+Ü Ø!Ø%Øô	
ˆô —}‘} Q¨Ó*ˆØ(¨,Ð7ˆçà˜
•NˆE÷:ñ :ð6 ˆE÷:ñ :ð2 
�<Ô	ä#×+Ò+ÜØ!Øô
ˆ÷ ä˜aŸk™k°˜kÓ:Ó;ˆJÜ˜qŸ|™|°8˜|Ó<Ó=ˆKØ*¨J¸ÀkÐRˆOä�K×&Ñ&Ó(Ó)ˆAØ •NˆE÷!Aò !AôJ ˜1Ÿ8™8¨8˜8Ó4Ó5ˆGØ'¨Ð1ˆOä˜Ÿ™Ó(Ó)ˆEØ Õ&ˆE÷:ñ :ð: 
Ð&Õ	&÷ Ü×"Ò"Ð#RÓSÐSò	ð ,ˆð $%§7¡7° 7Ô#<ÔGÑ#<™4˜1˜aÀÀQÁ—Q�QÑ#<ˆ	ÑGØ$%§G¡G° GÔ$=ÔHÑ$=™D˜A˜qÀÀaÁ—a�aÑ$=ˆ
ÑHô �q—x‘x x�xÓ0Ó1ˆÙ.7Ó8©i¨˜' !�*’}©iÑ8ˆØ×ÑÑ6©:Ó6Ô6Ù/9Ó:©z¨!˜7 1�:š©zÑ:ˆØ×ÑÑ6©IÓ6Ô6à'¨°mÀ\ÐRˆ÷	Tð 	Tô* ×ÒÐMÓNÐNä×ÒØHÈÈÐQó
ð 	
ñ
 	˜Ó%€AàÐÜ'0°¤|Ô4¡|™G˜A˜t��a’¡|€HÑ4ç
Ð
ô ˜Q ¨*¸4Ô@ˆñ QRÓRÑPQÈ1Ô'¨¨1¨j¸$ÖFÑPQˆ	ÐRÙ(1Ô@©	 1»a°d›$¹a™$©	ˆÑ@ñ    >Ó2ˆØ! A�I¨Ñ2ÐØˆô
 .¨a°¸OÓL‰ˆˆ8ð
 -.¯G©G¸¨GÔ,AÔBÑ,A¡  5ˆu�z‰zŽ|Ñ,AÒBÒBð —7‘7˜:Õ&ˆà�UŒ?Ø*¨=Õ9ˆLä×"Ò" 1 l°MÖBØ�|Ô#ßØ,¨[Õ9�
Ø-¨lÕ;“à)¨(Õ3“ØÐ*×*Ø)¨,Õ7ˆKØ*¨=Õ9‹LÙ
ùòm
 !ùóD Aùõùò, 7ùóH HùÛHùò 9ùâ:ùóR 5ùò SùÛ@ùó Cùsï   ‹Z�Y›=ZÁAZÂ*B-ZÅY
Å1
YÆ YÆY
ÆZÆ#BZÉY
ÉAZÊA
ZË'CZÎ+0ZÏYÏ,YÏ2ZÐ
Y$ÐY$Ð!"ZÑY*ÑZÑ4Y/ÒA1ZÓ7Y4ÔZÔZÔ%Y:Ô<ZÕY?Õ?ZÖZÖ2AZØ%ZØ/ZÙY
Ù:Zc                 ó”  aaa€ V Uu. uF  p\        4       NK  	  upoVP                  4        F  w  rVSV,          P                  V4       K  	  \        V4      pVP	                  V4       \
        P                  V4      pV'       Ed   \        \        V4      4      oVP                  S4       VS,          p	\        \        P                  ! V S4      4      p
V
 Uu0 uF  q±V,          kK  	  upV	0,
          pV'       g   K�  \        VVV3R  lV 4       4      w  rÞSV	,          pVS0,
          pTV'       d
   S! SV4      M^ 8”  g   KÇ  WáS&   VP                  S4       SV,          P                  S4       V
SV,          ,
          pVP                  R V 4       4       EK  S Uu. uF  pV'       g   K  VNK  	  up# u upi u upi u upi )c              3   óH   <"  € T F  pS! SSV,          4      V3x € K  	  R # 5ir&   r'   )r)   r¹   rÁ   rQ   r*   s   & €€€r   r,   Ú#_move_nodes_fast.<locals>.<genexpr>R  s!   øé € Ð LÁ8¸a¡*¨Q°°!µÓ"5°qÕ!9Ã8ùs   ƒ"c              3   ó(   "  € T F  qR 3x € K
  	  R # 5ir&   r'   )r)   r´   s   & r   r,   rÊ   `  s   é € ÐBÑ1A¨A $�iÓ1Aùr�   )rD   r4   ÚaddÚlistÚshuffler¥   r¦   rG   rH   r   r”   Úall_neighborsÚmaxÚremover©   )r   rÀ   rQ   r	   rÇ   r¿   rÄ   Ú
rand_nodesÚ
dict_dequeÚold_comÚu_nbrsr6   Únbr_comsÚbest_addÚbest_comÚ	P_old_comÚ	without_uÚnodes_to_revisitrÃ   rÁ   r*   s   &&f&               @@r   r«   r«   8  s|  ú€ Ù Ó!™�1ŒŽ™Ñ!€AØ—n‘nÖ&‰
ˆØ	ˆ$��‰�DÖñ 'ô �h“€JØ‡L�L�Ôô —‘˜zÓ*€Jß
ˆ*ä”�jÓ!Ó"ˆØ�‰�qÔà˜1•+ˆä”R×%Ò% a¨Ó+Ó,ˆÙ)/Ó0© A˜Q—K�K©Ñ0°G°9Õ<ˆßÙô !Ö LÁ8Ó LÓLÑˆð �g•Jˆ	Ø  •Oˆ	à·9‘z ! YÔ/À!ÖDØ"�Q‰KØ×Ñ˜QÔØˆh�K�O‰O˜AÔð  &¨¨(­Õ3ÐØ×ÑÑBÑ1AÓB×Bñ Ó‘q�!œA�AˆA‘qÑÐùòU 	"ùò( 1ùò, s   ˆF;ÃG Æ#
GÆ2Gc           
      óR  € \        V4       UUu/ uF'  w  rVYQV0,
          '       d   V! WaV0,
          4      M^ bK)  	  ppp\        V4       UUu/ uF  w  rVWu,          ^ 8”  g   K  WebK  	  pppV Uu. uF  qf0NK  	  p	pVP                  4        EF`  w  rj\        Wš,          4      ^8w  d   K  \        \        P
                  ! W4      4      p. p. p\        V	4       F[  w  r^Wë,          '       d   W¥8X  g   Wu,          ^ 8:  d   K(  V! Wn4      pV^ 8”  g   K9  VP                  V4       VP                  V4       K]  	  V'       g   Kµ  \        V4      pV Uu. uF'  p\        P                  ! VV,
          V,          4      NK)  	  ppVP                  VVR7      ^ ,          pWš,          P                  V4       ^ Wz&   V	V,          pVP                  V4       W,
          pV'       d
   V! VV4      M^ VV&   EKc  	  V	 Uu. uF  pV'       g   K  VNK  	  up# u uppi u uppi u upi u upi u upi )r$   )Úweights)rª   r4   rF   rD   r”   rÏ   ÚappendrÐ   ÚmathÚexpÚchoicesrÑ   rÌ   )r   r8   rQ   r	   r   r¾   r*   ÚTÚRÚ	C_refinedÚcomm_iÚunbrsÚ
cand_commsÚcand_comm_deltasÚnew_commÚQ_deltaÚ	max_deltaÚxÚcand_wtsÚ
new_comm_iÚ	C_removedr¹   s   &&&&&                 r   r¬   r¬   f  sç  € ô DMÈQÄ<ÔPÁ<¹4¸1ˆ¨A¨3§w¤w‰Z˜ ˜s�7Ô#°AÒ	5Á<€AÑPô $ Aœ,Ô3™,‘$�!¨!­$°©(ŒˆŠ™,€AÑ3áÓ ™a˜“™a€IÐ Ø—W‘W—Y‰	ˆô
 ˆyÕ Ó! QÔ&ÙÜ”B×$Ò$ QÓ*Ó+ˆàˆ
ØÐä$ YÖ/‰KˆAà×$Ô$¨¬¸½À¼	Ùá  Ó-ˆGØ˜Ž{Ø×!Ñ! !Ô$Ø ×'Ñ'¨Ö0ñ 0÷ ‰:ô Ð,Ó-ˆIÙCSÓTÑCS¸aœŸš ! i¥-°5Õ!8Ö9ÑCSˆHÐTØŸ™ j¸(˜ÓCÀAÕFˆJàÕ×$Ñ$ QÔ'ØˆA‰IØ  Õ,ˆHØ�L‰L˜ŒOð �ˆIß?H™J x°Ô;ÈaˆAˆjŒMñQ ñT !Ó&‘y�!¤A�AˆA‘yÑ&Ð&ùóa 	Qùó 	4ùâ ùò> Uùò 's)   �-HÁHÁ#HÁ0HÅ-HÇ6
H$ÈH$c                ó€  € V P                  RR7      p/ pV P                  4       p/ p^ pV Uu/ uF  qˆ/ bK  	  p	p\        V4       F¼  w  r«V F±  pW¦V&   V Uu/ uF  qÝ^ bK  	  pp\        4       pV FT  pWtV&   VP	                  VV,          4       VP                  4        F!  w  ppWè;;,          VV,          ,          uu&   K#  	  KV  	  VP                  WR7       V F  pWè,          W˜,          V&   K  	  V^,          pK³  	  K¾  	  V F  pW˜,          W(&   K  	  V P                  RR7       Fj  w  pppVV,          pVV,          pVP                  VV4      '       d&   VV,          V,          R;;,          V,          uu&   KV  VP                  VVVR7       Kl  	  VP                  P                  4        UUUUu/ uF=  w  ppTVP                  4        UUu/ uF  w  ppVV8w  g   K  VVR,          bK  	  uppbK?  	  pppppVP                  4       '       d‚   VP                  P                  4        Fc  w  ppVV,          pVP                  4        F@  w  ppVV8X  d   K  VV9   d   VV;;,          VR,          ,          uu&   K4  VR,          VV&   KB  	  Ke  	  VVP                  R&   WV3# u upi u upi u uppi u uppppi )a8  Return a new graph based on P_refined. Each community becomes a node.

Note: `node_attributes` is changed in place by this function!

P_refined is a list of lists of community sets. The outer list indicates
communities in the new graph which comes from P. Each inner list holds
the refined sets of nodes each of which becomes a new node. So P_refined
contains P as the outer list and its refinement as the inner lists which
hold the refined community sets that make up the new graph's nodes.

node_attributes is a dict keyed by each attribute name to be aggregated
which depends on the metric being used.
The value is a dict for that attribute keyed by node to the attribute value.
Aggregate means sum within a G community into a new node in H.
After this function the incoming dict values are replaced by aggregated dicts.
r!   r|   )r!   r
   r   r    )r!   Ú	__class__rª   rD   r©   r4   Úadd_noder›   rœ   r�   rŸ   r–   r    r¡   )r   rÂ   r¶   ÚG_original_nodesÚ	nodes_G2HÚHÚ
H_node2comÚ	H_node_idÚ	attr_nameÚH_node_attributesÚ	H_comm_idÚrefined_commsÚrefined_commÚ	attributeÚagg_valsÚoriginal_nodesÚG_nodeÚ	attr_dictr*   r6   r7   ÚH_uÚH_vr±   r²   Ú
H_edge_wtsr³   s   &&&                        r   r­   r­   Ÿ  s—  € ð" —w‘w G�wÓ,Ðà€IØ	�‰‹€AØ€JØ€IÙ8GÓH¹¨9 Bš¹ÐÐHÜ$-¨iÖ$8Ñ ˆ	Û)ˆLð %.�yÑ!Ù6EÓF±o¨ 1š±oˆHÐFô !›UˆNó '�Ø$-˜&Ñ!ð ×%Ñ%Ð&6°vÕ&>Ô?Ø,;×,AÑ,AÖ,CÑ(�I˜yØ×'¨9°VÕ+<Õ<Õ'ó -Dñ 'ð �J‰J�yˆJÔ7Û,�	Ø:BÕ:MÐ!Õ,¨YÓ7ñ -à˜�NŠIó+ *ñ %9ó8 %ˆ	Ø%6Õ%AˆÓ"ñ %ð —G‘G �GÖ*‰ˆˆ1ˆbØ˜�lˆØ˜�lˆØ�:‰:�c˜3×ÒØˆc�F�3�K˜×! RÕ'Õ!à�J‰J�s˜C¨ˆJÖ+ñ +ð —v‘v—|‘|”~öá%‰GˆAˆtð 	
¨¯©¬Ô@©¡  2¸¸a¹ŒOˆAˆr�(�|ŠO©Ò@Ò@Ù%ð ó ð 	‡}�}‡‚Ø—w‘w—}‘}–‰GˆAˆtØ˜q•MˆEØŸ™ž‘��2Ø˜”6ÙØ˜”:Ø˜!—H  8¥Õ,•Hà! (�|�E˜!“Hó &ñ 'ð %€A‡G�GˆJÑàˆ=Ðùòs Iùò GùóH Aùõs)   ­J(ÁJ-Æ7J8
ÇJ2Ç$J2Ç2J8
Ê2J8
)Ú__doc__r£   r   rß   ÚrandomÚcollectionsr   Únetworkxr”   Ú%networkx.algorithms.community.qualityr   r   Únetworkx.utilsr   r   Ú__all__Ú_dispatchabler   r   r«   r¬   r­   r'   r   r   Ú<module>r     s  ðÙ Mã Û Û Û Ý ã ß Rß ?àÐ!4Ð
5€ñ �ÓØ×Ò˜XÔ&ðI!ð ðI!ð ð	I!ð
 ðI!ð 
ðI!ð ðI!ð óI!ó 'ó ðI!ñX �ÓØ×Ò˜XÔ&ðUð ðUð ð	Uð
 ðUð 
ðUð óUó 'ó ðUòp+ò\6'ôrPr   