+
    �°³j\v  ã                   ó’  € R t ^ RIHt ^ RIt^ RIHtHtHt ^ RI	H
t
 . ROt]P                  ! RR7      RR l4       tR t]P                  ! RR7      RR	 l4       tR
 tR t]P                  ! RR7      RR l4       t]P                  R 4       t]
! R4      ]P                  R 4       4       t]
! R4      ]P                  R 4       4       tR# )zGroup centrality measures.)ÚdeepcopyN)Ú_accumulate_endpointsÚ"_single_source_dijkstra_path_basicÚ"_single_source_shortest_path_basic)Únot_implemented_forÚweight)Ú
edge_attrsc           
     óÔ  a aa*€ . pRp\         ;QJ d    V 3R lV 4       F  '       g   K   RM	  RM! V 3R lV 4       4      '       d   V.pRpV UUu0 uF  qw F  qˆkK  	  K  	  p	ppV	S P                  ,
          '       d,   \        P                  ! RV	S P                  ,
           R24      hS P	                  4       p
V
'       d   \        P
                  ! S 4      M\        P                  ! S 4      p\        S W“4      w  rÍo*V EFL  o\        S4      o^ p\        V4      p\        V4      pS EF<  pVVV,          V,          ,          pS*V,          pVV,          pVV,          pS EFÿ  pS*V,          pVV,          pVV,          pVV,          pVV,          pVV9   pVV9   pSVP                  4       ,           EF¨  pS*V,          pVV,          pVV,          p VV9   p!VV9   p"V!'       dr   VV,          VV,          VV,          ,           8X  dO   V'       dG   VV8w  d@   VV;;,          VV,          V,          VV,          V,          ,          V,          ,          uu&   V'       dd   VV,          VV,          VV,          ,           8X  dA   V '       d9   VV8w  d2   VV;;,          VV,          V,          V,          V ,          ,          uu&   V'       g   EK  V"'       g   EK#  VV,          VV,          VV,          ,           8X  g   EKI  V'       g   EKT  VV ,          p#VV;;,          ^V#V,          ,
          ,          uu&   VV;;,          V#,          uu&   VV8X  g   EKŸ  VV#,          pEK«  	  EK  	  EK?  	  \        S 4      p$V'       d   T$p%MŠ\        S4      p&V$V&,
          ;p'p%V'       d   V&V$^,
          V',           ,          p(MKV
'       d#   V*3R lS  4       p)\        V3R lV) 4       4      p(M!V*3R lS 4       p)\        V3R	 lV) 4       4      p(VV(,          pV'       d   VV%V%^,
          ,          ,          pMV
'       g
   V^,          pVP                  V4       EKO  	  V'       d   V# V^ ,          # u uppi )
u®  Compute the group betweenness centrality for a group of nodes.

Group betweenness centrality of a group of nodes $C$ is the sum of the
fraction of all-pairs shortest paths that pass through any vertex in $C$

.. math::

   c_B(v) =\sum_{s,t \in V} \frac{\sigma(s, t|v)}{\sigma(s, t)}

where $V$ is the set of nodes, $\sigma(s, t)$ is the number of
shortest $(s, t)$-paths, and $\sigma(s, t|C)$ is the number of
those paths passing through some node in group $C$. Note that
$(s, t)$ are not members of the group ($V-C$ is the set of nodes
in $V$ that are not in $C$).

Parameters
----------
G : graph
  A NetworkX graph.

C : list or set or list of lists or list of sets
  A group or a list of groups containing nodes which belong to G,
  for which group betweenness centrality is to be calculated.

normalized : bool, optional (default=True)
  If True, group betweenness is normalized by $1/(N_{out}(N_{out}-1))$
  where $N_{out}$ is the number of nodes in `G` that are not in `C`.
  This ensures the reported value is between 0 and 1.
  If `endpoints` is True, the normalization uses all nodes in `G`.
  The reported value is then between $2N_{in}/(N-1)$ and 1 where $N_{in}$
  is the number of nodes in `C` and $N$ the number of nodes in `G`.

weight : None or string, optional (default=None)
  If None, all edge weights are considered equal.
  Otherwise holds the name of the edge attribute used as weight.
  The weight of an edge is treated as the length or distance between the two sides.

endpoints : bool, optional (default=False)
  By default, only node-pairs that are both not in `C` are counted for
  group betweenness centrality. The count is how many non-`C` node-pairs have
  nodes from `C` "between" them on a shortest path.

  When ``endpoints=True``, we also count node-pairs with one or both nodes
  in `C` while considering endpoint nodes as being between the node-pairs.
  So we count paths that start in `C` whether or not they pass through
  any other nodes in `C`. This adds centrality to large groups without any
  reference to the connectivity of the group. The minimum normalized score
  is $N_{in}(N_{in}-1)/(N(N-1))$ instead of 0. For that reason, this feature
  is rarely used.

  We don't currently support considering node-pairs with nodes in `C` without
  also counting their endpoints. Nor do we support counting endpoints while
  only considering node-pairs that are both not in `C`. This keyword indicates
  both coutning endpoints of paths and allowing node-pairs in C.

Raises
------
NodeNotFound
   If node(s) in `C` are not present in `G`.

Returns
-------
betweenness : list of floats or float
   If `C` is a single group then return a float. If `C` is a list with
   several groups then return a list of group betweenness centralities.

See Also
--------
betweenness_centrality

Notes
-----
Group betweenness centrality is defined in [1]_ and discussed in [3]_.
The algorithm is described in [2]_ and is based on techniques mentioned in [4]_.

The number of nodes in the group must be a maximum of ``N - 2`` where ``N``
is the total number of nodes in the graph.

For weighted graphs the edge weights must be greater than zero.
Zero edge weights can produce an infinite number of equal length
paths between pairs of nodes.

The total number of paths between source and target is counted
differently for directed and undirected graphs. Directed paths
between "u" and "v" are counted as two possible paths (one each
direction) while undirected paths between "u" and "v" are counted
as one path. Said another way, the sum in the expression above is
over all ``s != t`` for directed graphs and for ``s < t`` for undirected graphs.


References
----------
.. [1] M G Everett and S P Borgatti:
   The Centrality of Groups and Classes.
   Journal of Mathematical Sociology. 23(3): 181-201. 1999.
   http://www.analytictech.com/borgatti/group_centrality.htm
.. [2] Ulrik Brandes:
   On Variants of Shortest-Path Betweenness
   Centrality and their Generic Computation.
   Social Networks 30(2):136-145, 2008.
   http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.9610&rep=rep1&type=pdf
.. [3] Sourav Medya et. al.:
   Group Centrality Maximization via Network Design.
   SIAM International Conference on Data Mining, SDM 2018, 126â€“134.
   https://sites.cs.ucsb.edu/~arlei/pubs/sdm18.pdf
.. [4] Rami Puzis, Yuval Elovici, and Shlomi Dolev.
   "Fast algorithm for successive computation of group betweenness centrality."
   https://journals.aps.org/pre/pdf/10.1103/PhysRevE.76.056709

Tc              3   ó,   <"  € T F	  qS9   x € K  	  R # 5i©N© )Ú.0ÚelÚGs   & €Úe/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/centrality/group.pyÚ	<genexpr>Ú/group_betweenness_centrality.<locals>.<genexpr>Š   s   øé € Ð
™Q�r�Ž7›Qùs   ƒFúThe node(s) ú are in C but not in G.c              3   óZ   <"  € T F   pSV,           F  q"V8w  g   K  W3x € K  	  K"  	  R # 5ir   r   ©r   ÚuÚvÚDs   &  €r   r   r   Ý   s'   øé € ÐH©a¨¸¸1¿¸°AÀaÁœf˜q�f¹™f«aùó   ƒ+œ+c              3   óL   <"  € T F  w  rVS9   g
   VS9   g   K  ^x € K  	  R# 5i©é   Nr   ©r   r   r   Úgroups   &  €r   r   r   Þ   s!   øé € ÐS©*¡$ !¸¸e¼ÀqÈEÁzŸAšA«*ùs   ƒ$š
$c              3   óZ   <"  € T F   pSV,           F  q"V8w  g   K  W3x € K  	  K"  	  R # 5ir   r   r   s   &  €r   r   r   â   s'   øé € ÐL©e¨¸Q¸q¿T¸T¸È!ÁVœf˜q�f¹T™f«eùr   c              3   ó>   <"  € T F  w  rVS9   d   ^M^x € K  	  R# 5ir   r   r   s   &  €r   r   r   ã   s   øé € ÐLÁ¹¸ ! u¤*™Q°!Ô3Ãùs   ƒ)ÚanyÚnodesÚnxÚNodeNotFoundÚis_directedÚis_strongly_connectedÚis_connectedÚ_group_preprocessingÚsetr   ÚkeysÚlenÚsumÚappend)+r   ÚCÚ
normalizedr   Ú	endpointsÚGBCÚlist_of_groupsr   ÚnodeÚset_vr&   Ú	connectedÚPBÚsigmaÚ	GBC_groupÚsigma_mÚPB_mr   ÚDvÚPB_vÚsig_vÚxÚDxÚPB_xÚsig_xÚsig_xvÚsig_vxÚx_in_DvÚv_in_DxÚyÚDyÚsig_xyÚsig_vyÚv_in_DyÚy_in_DvÚsig_xvyÚNÚNscaleÚN_inÚN_outÚextraÚ
reachablesr   s+   f&&&&  `                                  @r   Úgroup_betweenness_centralityrT      sƒ  ú€ ð` €CØ€Nç
ƒsÔ
™QÓ
‡s‡s‚sÔ
™QÓ
×ÒØˆCˆØˆÙ Ô3™q�eªU TŠT©U‰T™q€EÑ3Øˆq�w‰w‡„Ü�oŠo ¨U°Q·W±W­_Ð,=Ð=TÐUÓVÐVð —-‘-“/€Kß/:”×(Ò(¨Ô+ÄÇÂÐPQÓ@R€Iô (¨¨5Ó9�L€Bˆqô ˆÜ�E“
ˆàˆ	Ü˜5“/ˆÜ˜‹|ˆÜˆAà˜˜a� �Õ#ˆIð �1•ˆBØ˜•7ˆDØ˜A•JˆEä�à�q•T�Ø˜A•w�Ø �
�Ø˜q��Ø˜q��Ø˜r™'�Ø˜r™'�ð  §¡£×*Ñ*�Aà˜1��BØ" 1�X�FØ" 1�X�FØ 2™g�GØ 2™g�G÷  2 a¥5¨B¨q­E°B°qµE­MÔ#9¿fØ œ6Ø  ŸG t¨A¥w°Õ'7¸'À!½*ÀQ½-Õ'GÈ&Õ'PÕP›Gç 2 a¥5¨B¨q­E°B°qµE­MÔ#9¿fØ œ6à  ŸG t¨A¥w°Õ'7¸&Õ'@À6Õ'IÕI›Gç’w§7¢7¨r°!­u¸¸1½ÀÀ1Å½×/EÏ&Ê&Ø"(¨6¥/˜Ø˜QŸ 1 w°Õ'7Õ#7Õ7›Ø˜aŸ GÕ+›Ø Ÿ6à" gÕ-›Fô1 +ô ñ ô\ �‹FˆßØ‰Fä�u“:ˆDØ �XÐ%ˆE�F÷ ð   A¥¨¥Õ.‘ßäH©aÓH�
ÜÔS©*ÓSÓS‘ô M©eÓL�
ÜÔLÁÓLÓL�à˜ÕˆI÷ Ø˜ 6¨A¥:Õ.Õ.‰IßØ˜�NˆIà�
‰
�9×ñi ÷j Øˆ
Øˆq�6€MùóG 4s   ÁQ$c           	      ó¨  € / p/ p/ p\         P                  V ^ 4      pV  F�  pVf   \        W4      w  r‰W7&   WW&   M\        WV4      w  r‰W7&   WW&   \	        WhW“V,          V4      w  qdV&   WG,           FI  p
Wz8w  d   WG,          V
;;,          ^,          uu&   Vf   K*  W7,          V
,          ^,          W7,          V
&   KK  	  KŸ  	  \         P                  V 4      pV Fõ  p\         P                  V R4      W¼&   V FÔ  pWÕV,          9  d   K  V  F¼  pWÕV,          9   g   K  WÅV,          9   g   K!  W^,          V,          W^,          V,          W\,          V,          ,           8X  g   KX  W¼,          V;;,          WN,          V,          W>,          V,          ,          W<,          V,          ,          W>,          V,          ,          ,          uu&   K¾  	  KÖ  	  K÷  	  W³V3# )é    g        )ÚdictÚfromkeysr   r   r   )r   r5   r   r8   Údeltar   ÚbetweennessÚsÚSÚPÚir7   Úgroup_node1Úgroup_node2r4   s   &&&            r   r)   r)   ó   s”  € Ø€EØ€EØ
€AÜ—-‘-  1Ó%€KÛˆØŠ>Ü#EÀaÓ#KÑ ˆA�%‘(˜AšDä#EÀaÈFÓ#SÑ ˆA�%‘(˜A™DÜ 5°kÀaÈqÍÐSTÓ UÑˆ˜1‘XØ—�ˆAØŒvØ•˜—˜qÕ “ØÔ!Ø#�h q�k¨A�o�•˜“ó	 ñ ô 
�‰�qÓ	€BÛˆÜŸ-™-¨¨3Ó/ˆ‰Û ˆKØ K¥.Ô0ÙÛ�à D¥'Ö)¨k¸t½WÖ.Dà� Õ,Ø�7 ;Õ/°!µ.ÀÕ2MÕMöNð �¨×4Ø!�K¨Õ4Ø#�k¨+Õ6õ7à#Õ0°Õ=õ>ð $�k¨+Õ6õ7õÕ4ó ó !ñ ð$ �aˆ<Ðó    c                óô  € ^ RI p^ RIpVek   \        V4      pW0P                  ,
          '       d+   \        P
                  ! RW0P                  ,
           R24      h\        V P                  V,
          4      p	M\        V P                  4      p	\        P                  ! 4       p
RV
n        \        W	V4      w  r¼pVP                  P                  V4      pVe.   V F'  pVP                  VR7      pVP                  VR7      pK)  	  \        \        VP                  V4      V	4      RR7       UUu. uF  w  pqÿNK	  	  ppp^ p. pV
P!                  ^VV^ . V\#        \        W—P                  V4      4      4      R7       ^ V
P                  ^,          R	&   \%        V4       Fg  pV
P                  ^,          R	;;,          V
P                  ^,          R
,          V
P                  ^,          R,          V,          ,          ,          uu&   Ki  	  \'        WV
V^VVW–4	      w  pp
p\)        V 4      pV'       gá   ^ p\        P*                  ! V 4      '       d<   \        P,                  ! V 4      '       d   V^V,          V,
          ^,
          ,          pM:\        P.                  ! V 4      '       d   V^V,          V,
          ^,
          ,          pV^ 8X  d>   V F7  pVV,           F'  pVV8w  g   K  VV9   d   V^,          pK  V^,          pK)  	  K9  	  VV,          pV'       d0   ^VV,
          VV,
          ^,
          ,          ,          pVV,          pMV P+                  4       '       g
   V^,          p\1        VR 4      pVV3# u uppi )u  Find the prominent group of size $k$ in graph $G$. The prominence of the
group is evaluated by the group betweenness centrality.

Group betweenness centrality of a group of nodes $C$ is the sum of the
fraction of all-pairs shortest paths that pass through any vertex in $C$

.. math::

   c_B(v) =\sum_{s,t \in V} \frac{\sigma(s, t|v)}{\sigma(s, t)}

where $V$ is the set of nodes, $\sigma(s, t)$ is the number of
shortest $(s, t)$-paths, and $\sigma(s, t|C)$ is the number of
those paths passing through some node in group $C$. Note that
$(s, t)$ are not members of the group ($V-C$ is the set of nodes
in $V$ that are not in $C$).

Parameters
----------
G : graph
   A NetworkX graph.

k : int
   The number of nodes in the group.

normalized : bool, optional (default=True)
   If True, group betweenness is normalized by ``1/((|V|-|C|)(|V|-|C|-1))``
   where ``|V|`` is the number of nodes in G and ``|C|`` is the number of
   nodes in C.

weight : None or string, optional (default=None)
   If None, all edge weights are considered equal.
   Otherwise holds the name of the edge attribute used as weight.
   The weight of an edge is treated as the length or distance between the two sides.

endpoints : bool, optional (default=False)
   If True include the endpoints in the shortest path counts.

C : list or set, optional (default=None)
   list of nodes which won't be candidates of the prominent group.

greedy : bool, optional (default=False)
   Using a naive greedy algorithm in order to find non-optimal prominent
   group. For scale free networks the results are negligibly below the optimal
   results.

Raises
------
NodeNotFound
   If node(s) in C are not present in G.

Returns
-------
max_GBC : float
   The group betweenness centrality of the prominent group.

max_group : list
    The list of nodes in the prominent group.

See Also
--------
betweenness_centrality, group_betweenness_centrality

Notes
-----
Group betweenness centrality is defined in [1]_ and discussed in [3]_.
The algorithm is described in [2]_ and is based on techniques mentioned in [4]_.

The number of nodes in the group must be a maximum of ``N - 2`` where ``N``
is the total number of nodes in the graph.

For weighted graphs the edge weights must be greater than zero.
Zero edge weights can produce an infinite number of equal length
paths between pairs of nodes.

The total number of paths between source and target is counted
differently for directed and undirected graphs. Directed paths
between "u" and "v" are counted as two possible paths (one each
direction) while undirected paths between "u" and "v" are counted
as one path. Said another way, the sum in the expression above is
over all ``s != t`` for directed graphs and for ``s < t`` for undirected graphs.

References
----------
.. [1] M G Everett and S P Borgatti:
   The Centrality of Groups and Classes.
   Journal of Mathematical Sociology. 23(3): 181-201. 1999.
   http://www.analytictech.com/borgatti/group_centrality.htm
.. [2] Rami Puzis, Yuval Elovici, and Shlomi Dolev:
   "Finding the Most Prominent Group in Complex Networks"
   AI communications 20(4): 287-296, 2007.
   https://www.researchgate.net/profile/Rami_Puzis2/publication/220308855
.. [3] Sourav Medya et. al.:
   Group Centrality Maximization via Network Design.
   SIAM International Conference on Data Mining, SDM 2018, 126â€“134.
   https://sites.cs.ucsb.edu/~arlei/pubs/sdm18.pdf
.. [4] Rami Puzis, Yuval Elovici, and Shlomi Dolev.
   "Fast algorithm for successive computation of group betweenness centrality."
   https://journals.aps.org/pre/pdf/10.1103/PhysRevE.76.056709
Nr   r   )Úindex)ÚcolumnsT©Úreverse)ÚCLrZ   r2   ÚGMr8   ÚcontÚheuri   rg   z.2f)ÚnumpyÚpandasr*   r#   r$   r%   ÚlistÚGraphÚ__networkx_cache__r)   Ú	DataFrameÚ	from_dictÚdropÚsortedÚzipÚdiagÚadd_noderW   ÚrangeÚ_dfbnbr,   r&   r'   r(   Úfloat)r   Úkr   r/   r1   r0   ÚgreedyÚnpÚpdr#   ÚDF_treer7   r8   r   rZ   r4   Ú_rg   Úmax_GBCÚ	max_groupr^   r   Úscaler_   s   &&&&&&&                 r   Úprominent_grouprƒ     sé  € óN Ûà‚}Ü�‹FˆØ�w‰w�;Œ;Ü—/’/ L°·W±Wµ°Ð=TÐ"UÓVÐVÜ�Q—W‘W˜q•[Ó!‰ä�Q—W‘W“ˆÜ�hŠh‹j€GØ!%€GÔÜ'¨°&Ó9�L€BˆqØ—,‘,×(Ñ(¨Ó,€KØ‚}ÛˆDà%×*Ñ*°Ð*Ó6ˆKØ%×*Ñ*°4Ð*Ó8ŠKñ ô %¤S¨¯©°Ó)=¸uÓ%EÈtÕTÔ	UÑT‘7�1�dŠ$ÑT€BÑ	UØ€GØ€IØ×ÑØ	ØØØØØÜ”#�eŸW™W [Ó1Ó2Ó3ð ô ð  €G‡M�M�!Õ�UÑÜ�1ŽXˆØ�‰�aÕ˜× 7§=¡=°Õ#3°FÕ#;¸G¿M¹MÈ!Õ<LÈTÕ<RÐSTÕ<UÕ#VÕVÕñ ä"(Ø	ˆg�w  1 i°ó#Ñ€GˆW�iô 	ˆA‹€AßØˆô �>Š>˜!×ÒÜ×'Ò'¨×*Ò*Ø˜Q �U Q�Y¨�]Õ+�øÜ�_Š_˜Q×ÒØ˜˜Q� � Q�Õ'ˆEØ�AŒ:Û(�Ø˜kŸN˜N�DØ˜{Ö*Ø 9Ô,Ø! Q�JšEà! Q�JšEó +ñ  )ð 	�5Õˆ÷ Ø�a˜!•e  A¥¨¥	Õ*Õ+ˆØ�5Õ‰ð �]‰]�_Š_Ø�1�ˆÜ�w˜s�mÓ%€GØ�IÐÐùóg 
Vs   Ä,M4c	                 óF  € \        VP                  V,          R ,          4      V8X  dT   VP                  V,          R,          V8”  d5   VP                  V,          R,          W"P                  V,          R ,          3# \        VP                  V,          R ,          4      V8X  g�   \        VP                  V,          R,          4      V\        VP                  V,          R ,          4      ,
          8:  g?   VP                  V,          R,          VP                  V,          R,          ,           V8:  d   W2V3# \        WW%Wx4      w  ršpV'       d   \        WW#W•WgV4	      w  r2pM¾VP                  V	,          R,          VP                  V	,          R,          ,           VP                  V
,          R,          VP                  V
,          R,          ,           8”  d&   \        WW#W•WgV4	      w  r2p\        WW#W¥WgV4	      w  r2pM$\        WW#W¥WgV4	      w  r2p\        WW#W•WgV4	      w  r2pW2V3# )rh   r2   rg   rj   )r,   r#   Ú
_heuristicrx   )r   rz   r~   r€   Úrootr   r�   r#   r{   Únode_pÚnode_ms   &&&&&&&&&  r   rx   rx   Ê  sÞ  € ä
ˆ7�=‰=˜Õ˜tÕ$Ó%¨Ô*¨w¯}©}¸TÕ/BÀ5Õ/IÈGÔ/SØ�}‰}˜TÕ" 5Õ)¨7·M±MÀ$Õ4GÈÕ4MÐMÐMô
 	ˆG�M‰M˜$Õ Õ%Ó&¨!Ô+Üˆw�}‰}˜TÕ" 4Õ(Ó)¨Q´°W·]±]À4Õ5HÈÕ5NÓ1OÕ-OÔOØ�=‰=˜Õ˜uÕ%¨¯©°dÕ(;¸EÕ(BÕBÀgÔMà Ð*Ð*ô )¨°'¸eÓLÑ€F�G÷ Ü&,Ø�' F¨yÀó'
Ñ#ˆ™)ð
 	�‰�fÕ˜eÕ$ w§}¡}°VÕ'<¸UÕ'CÕCØ
�-‰-˜Õ
 Õ
&¨¯©°vÕ)>¸uÕ)EÕ
Eô	Fô '-Ø�' F¨yÀó'
Ñ#ˆ˜)ô '-Ø�' F¨yÀó'
Ñ#ˆ™)ô '-Ø�' F¨yÀó'
Ñ#ˆ˜)ô '-Ø�' F¨yÀó'
Ñ#ˆ˜)ð ˜YÐ&Ð&ra   c           	      ój  € ^ RI pVP                  4       ^,           pVP                  4       ^,           pVP                  V,          R,          ^ ,          p	VP                  V\	        VP                  V,          4      3.4       VP                  V,          R,          P                  V	4       VP                  V,          R;;,          VP                  V,          R,          V	,          ,          uu&   VP                  V,          p
V EFV  pV EFK  p^ p^ p^ pV
R,          V,          V,          ^ 8X  EgÇ   V
R,          V,          V	,          ^ 8X  Egª   V
R,          V	,          V,          ^ 8X  Eg�   W;,          V	,          W;,          V,          W<,          V	,          ,           8X  dP   V
R,          V,          V,          V
R,          V,          V	,          ,          V
R,          V,          V	,          ,          pW;,          V,          W;,          V	,          W9,          V,          ,           8X  dP   V
R,          V,          V	,          V
R,          V	,          V,          ,          V
R,          V,          V,          ,          pW9,          V,          W9,          V,          W;,          V,          ,           8X  dP   V
R,          V	,          V,          V
R,          V,          V,          ,          V
R,          V	,          V,          ,          pV
R,          V,          V,          ^V,
          ,          VP                  V,          R,          V,          V&   V
R,          V,          V,          V
R,          V,          V,          V,          ,
          VP                  V,          R,          P                  WË3&   WÉ8w  dU   VP                  V,          R,          P                  WË3;;,          V
R,          V,          V	,          V,          ,          uu&   W¹8w  g   EK÷  VP                  V,          R,          P                  WË3;;,          V
R,          V	,          V,          V,          ,          uu&   EKN  	  EKY  	  \        \        VP                  VP                  V,          R,          4      V4      RR	7       UUu. uF)  w  ppVVP                  V,          R,          9  g   K'  VNK+  	  uppVP                  V,          R&   \        \        WFP                  VP                  V,          R,          4      4      4      VP                  V,          R&   ^ VP                  V,          R
&   \        V \        VP                  V,          R,          4      ,
          4       Fg  pVP                  V,          R
;;,          VP                  V,          R,          VP                  V,          R,          V,          ,          ,          uu&   Ki  	  V'       Eg6   VP                  V\	        VP                  V,          4      3.4       VP                  V,          R,          P                  ^ 4       VP                  V,          R,          P                  V	4       ^ VP                  V,          R
&   \        V \        VP                  V,          R,          4      ,
          4       Fg  pVP                  V,          R
;;,          VP                  V,          R,          VP                  V,          R,          V,          ,          ,          uu&   Ki  	  MRpWxV3# u uppi )rV   Nrg   rh   r2   ri   r8   rZ   Tre   rj   )rk   Únumber_of_nodesr#   Úadd_nodes_fromr   r.   Úlocrs   rt   ru   rW   rw   r,   Úpop)rz   r†   r~   r   r#   r{   r|   r‡   rˆ   Ú
added_nodeÚ	root_noder?   rG   ÚdxvyÚdxyvÚdvxyr   r4   r^   s   &&&&&&             r   r…   r…   ö  s•  € Ûð ×$Ñ$Ó&¨Õ*€FØ×$Ñ$Ó&¨Õ*€FØ—‘˜tÕ$ TÕ*¨1Õ-€Jð ×Ñ˜V¤X¨g¯m©m¸DÕ.AÓ%BÐCÐDÔEØ‡M�M�&Õ˜$Õ×&Ñ& zÔ2Ø‡M�M�&Õ˜%×  G§M¡M°&Õ$9¸&Õ$AÀ*Õ$MÕMÓ Ø—‘˜dÕ#€IÜˆÜˆAØˆDØˆDØˆDà˜'Õ" 1Õ% aÕ(¨AÕ-Ø˜WÕ% aÕ(¨Õ4¸Õ9Ø˜WÕ% jÕ1°!Õ4¸Õ9à•4˜
Õ# q¥t¨A¥w°µ°jÕ1AÕ'AÔAà! 'Õ*¨1Õ-¨aÕ0Ø# GÕ,¨QÕ/°
Õ;õ<à# GÕ,¨QÕ/°
Õ;õ<ð ð
 •4˜•7˜a�d :Õ.°µ¸qÕ1AÕAÔAà! 'Õ*¨1Õ-¨jÕ9Ø# GÕ,¨ZÕ8¸Õ;õ<à# GÕ,¨QÕ/°Õ2õ3ð ð
 •= Õ# q¥}°QÕ'7¸!½$¸q½'Õ'AÔAà! 'Õ*¨:Õ6°qÕ9Ø# GÕ,¨QÕ/°Õ2õ3à# GÕ,¨ZÕ8¸Õ;õ<ð ð
 4=¸WÕ3EÀaÕ3HÈÕ3KÈqÐSWÍxÕ3XˆG�M‰M˜&Õ! 'Õ*¨1Õ-¨aÑ0à˜-Õ(¨Õ+¨AÕ.°¸=Õ1IÈ!Õ1LÈQÕ1OÐRVÕ1VÕVð �M‰M˜&Õ! -Õ0×4Ñ4°Q°TÑ:ð ŒØ—‘˜fÕ% mÕ4×8Ñ8¸¸×>Ø˜mÕ,¨QÕ/°
Õ;¸dÕBõÓ>ð �Ø—‘˜fÕ% mÕ4×8Ñ8¸¸×>Ø˜mÕ,¨ZÕ8¸Õ;¸dÕBõÖ>ôI ñ ôV Ü�—‘˜Ÿ™ fÕ-¨mÕ<Ó=¸uÓEÈtõ
ô#ñ
‰GˆAˆtð �w—}‘} VÕ,¨TÕ2Ñ2÷	 	ˆñ
ò#€G‡M�M�&Õ˜$Ñô %)ÜˆE—7‘7˜7Ÿ=™=¨Õ0°Õ?Ó@ÓAó%€G‡M�M�&Õ˜&Ñ!ð $%€G‡M�M�&Õ˜%Ñ Ü�1”s˜7Ÿ=™=¨Õ0°Õ6Ó7Õ7Ö8ˆØ�‰�fÕ˜e×$¨¯©°fÕ(=¸fÕ(EØ�M‰M˜&Õ! $Õ'¨Õ*õ)
õ 	
Õ$ñ 9÷ ˆ6Ø×Ñ ¬°'·-±-ÀÕ2EÓ)FÐ GÐHÔIØ�‰�fÕ˜dÕ#×'Ñ'¨Ô*Ø�‰�fÕ˜fÕ%×)Ñ)¨*Ô5Ø'(ˆ�‰�fÕ˜eÑ$Ü�qœ3˜wŸ}™}¨VÕ4°TÕ:Ó;Õ;Ö<ˆAØ�M‰M˜&Õ! %×(¨G¯M©M¸&Õ,AÀ&Õ,IØ—‘˜fÕ% dÕ+¨AÕ.õ-õ Õ(ò =ð
 ˆà˜7Ð"Ð"ùó=#s   Ò!$\/Ó
\/c                óx  € V P                  4       '       d   V P                  4       p ^ p\        V 4      p\        V4      pWA,
          p\        P                  ! WVR7      pV F  p W6V,          ,          pK  	   \        V4      V,          pV#   \
         d    T^ ,          p KC  i ; i  \         d    ^ p T# i ; i)ah  Compute the group closeness centrality for a group of nodes.

Group closeness centrality of a group of nodes $S$ is a measure
of how close the group is to the other nodes in the graph.

.. math::

   c_{close}(S) = \frac{|V-S|}{\sum_{v \in V-S} d_{S, v}}

   d_{S, v} = min_{u \in S} (d_{u, v})

where $V$ is the set of nodes, $d_{S, v}$ is the distance of
the group $S$ from $v$ defined as above. ($V-S$ is the set of nodes
in $V$ that are not in $S$).

Parameters
----------
G : graph
   A NetworkX graph.

S : list or set
   S is a group of nodes which belong to G, for which group closeness
   centrality is to be calculated.

weight : None or string, optional (default=None)
   If None, all edge weights are considered equal.
   Otherwise holds the name of the edge attribute used as weight.
   The weight of an edge is treated as the length or distance between the two sides.

Raises
------
NodeNotFound
   If node(s) in S are not present in G.

Returns
-------
closeness : float
   Group closeness centrality of the group S.

See Also
--------
closeness_centrality

Notes
-----
The measure was introduced in [1]_.
The formula implemented here is described in [2]_.

Higher values of closeness indicate greater centrality.

It is assumed that 1 / 0 is 0 (required in the case of directed graphs,
or when a shortest path length is 0).

The number of nodes in the group must be a maximum of ``N - 1`` where ``N``
is the total number of nodes in the graph.

For directed graphs, the incoming distance is utilized here. To use the
outward distance, act on `G.reverse()`.

For weighted graphs the edge weights must be greater than zero.
Zero edge weights can produce an infinite number of equal length
paths between pairs of nodes.

References
----------
.. [1] M G Everett and S P Borgatti:
   The Centrality of Groups and Classes.
   Journal of Mathematical Sociology. 23(3): 181-201. 1999.
   http://www.analytictech.com/borgatti/group_centrality.htm
.. [2] J. Zhao et. al.:
   Measuring and Maximizing Group Closeness Centrality over
   Disk Resident Graphs.
   WWWConference Proceedings, 2014. 689-694.
   https://doi.org/10.1145/2567948.2579356
)r   )r&   rf   r*   r$   Ú!multi_source_dijkstra_path_lengthÚKeyErrorr,   ÚZeroDivisionError)r   r\   r   Ú	closenessÚVÚV_SÚshortest_path_lengthsr   s   &&&     r   Úgroup_closeness_centralityr›   N  s¸   € ðZ 	‡}�}‡‚Ø�I‰I‹KˆØ€IÜˆA‹€AÜˆA‹€AØ
�%€CÜ×@Ò@ÀÈfÔUÐãˆð	Ø¨qÕ1Õ1ŠIñ ð
Ü˜“H˜yÕ(ˆ	ð Ðøô ô 	Ø˜�N‹Ið	ûô ô Ø‰	ØÐðús$   Á%BÁ9B( ÂB%Â$B%Â(B9Â8B9c                ó"  € \        \        4       P                  ! V Uu. uF  p\        V P                  V4      4      NK  	  up!  \        V4      ,
          4      pV\        V P	                  4       4      \        V4      ,
          ,          pV# u upi )aÃ  Compute the group degree centrality for a group of nodes.

Group degree centrality of a group of nodes $S$ is the fraction
of non-group members connected to group members.

Parameters
----------
G : graph
   A NetworkX graph.

S : list or set
   S is a group of nodes which belong to G, for which group degree
   centrality is to be calculated.

Raises
------
NetworkXError
   If node(s) in S are not in G.

Returns
-------
centrality : float
   Group degree centrality of the group S.

See Also
--------
degree_centrality
group_in_degree_centrality
group_out_degree_centrality

Notes
-----
The measure was introduced in [1]_.

The number of nodes in the group must be a maximum of n - 1 where `n`
is the total number of nodes in the graph.

References
----------
.. [1] M G Everett and S P Borgatti:
   The Centrality of Groups and Classes.
   Journal of Mathematical Sociology. 23(3): 181-201. 1999.
   http://www.analytictech.com/borgatti/group_centrality.htm
)r,   r*   ÚunionÚ	neighborsr#   )r   r\   r^   Ú
centralitys   &&  r   Úgroup_degree_centralityr    ¯  sh   € ô\ ”S“U—[’[ÁÓ"BÁ¸1¤3 q§{¡{°1£~Ö#6ÁÑ"BÑCÄcÈ!ÃfÕLÓM€JØ”#�a—g‘g“i“.¤3 q£6Õ)Õ)€JØÐùò #Cs   ž#BÚ
undirectedc                ó6   € \        V P                  4       V4      # )a�  Compute the group in-degree centrality for a group of nodes.

Group in-degree centrality of a group of nodes $S$ is the fraction
of non-group members connected to group members by incoming edges.

Parameters
----------
G : graph
   A NetworkX graph.

S : list or set
   S is a group of nodes which belong to G, for which group in-degree
   centrality is to be calculated.

Returns
-------
centrality : float
   Group in-degree centrality of the group S.

Raises
------
NetworkXNotImplemented
   If G is undirected.

NodeNotFound
   If node(s) in S are not in G.

See Also
--------
degree_centrality
group_degree_centrality
group_out_degree_centrality

Notes
-----
The number of nodes in the group must be a maximum of n - 1 where `n`
is the total number of nodes in the graph.

`G.neighbors(i)` gives nodes with an outward edge from i, in a DiGraph,
so for group in-degree centrality, the reverse graph is used.
)r    rf   ©r   r\   s   &&r   Úgroup_in_degree_centralityr¤   â  s   € ôX # 1§9¡9£;°Ó2Ð2ra   c                ó   € \        W4      # )a’  Compute the group out-degree centrality for a group of nodes.

Group out-degree centrality of a group of nodes $S$ is the fraction
of non-group members connected to group members by outgoing edges.

Parameters
----------
G : graph
   A NetworkX graph.

S : list or set
   S is a group of nodes which belong to G, for which group in-degree
   centrality is to be calculated.

Returns
-------
centrality : float
   Group out-degree centrality of the group S.

Raises
------
NetworkXNotImplemented
   If G is undirected.

NodeNotFound
   If node(s) in S are not in G.

See Also
--------
degree_centrality
group_degree_centrality
group_in_degree_centrality

Notes
-----
The number of nodes in the group must be a maximum of n - 1 where `n`
is the total number of nodes in the graph.

`G.neighbors(i)` gives nodes with an outward edge from i, in a DiGraph,
so for group out-degree centrality, the graph itself is used.
)r    r£   s   &&r   Úgroup_out_degree_centralityr¦     s   € ôX # 1Ó(Ð(ra   )rT   r›   r    r¤   r¦   rƒ   )TNF)NNFTFr   )Ú__doc__Úcopyr   Únetworkxr$   Ú*networkx.algorithms.centrality.betweennessr   r   r   Únetworkx.utils.decoratorsr   Ú__all__Ú_dispatchablerT   r)   rƒ   rx   r…   r›   r    r¤   r¦   r   ra   r   Ú<module>r®      s  ðÙ  å ã ÷ñ õ
 :ò€ð ×Ò˜XÔ&óXó 'ðXòv$ðN ×Ò˜XÔ&óló 'ðlò^)'òXU#ðp ×Ò˜XÔ&ó]ó 'ð]ð@ ×Ññ/ó ð/ñd �\Ó"Ø×Ññ*3ó ó #ð*3ñZ �\Ó"Ø×Ññ*)ó ó #ò*)ra   