§
    bŠtjË  ã                   ó’   — d Z ddlmZ ddlZddgZ ej        d¬¦  «        dd	„¦   «         Zdd„ZeZ	ej        dd„¦   «         Z
dd„ZdS )zLoad centrality.é    )Ú
itemgetterNÚload_centralityÚedge_load_centralityÚweight)Ú
edge_attrsTc                 óÔ  — |�[d}| D ]&}t          | ||d|¦  «        }|||v r||         ndz  }Œ'|r-|                      ¦   «         }|dk    r|S |d|dz
  |dz
  z  z  z  }nŠi                      | d¦  «        }|D ]0}t          | ||d|¦  «        }|D ]}	||	xx         ||	         z  cc<   ŒŒ1|r?|                      ¦   «         }|dk    r|S d|dz
  |dz
  z  z  }
|D ]}||xx         |
z  cc<   Œ|S )u  Compute load centrality for nodes.

    The load centrality of a node is the fraction of all shortest
    paths that pass through that node.

    Parameters
    ----------
    G : graph
      A networkx graph.

    normalized : bool, optional (default=True)
      If True the betweenness values are normalized by b=b/(n-1)(n-2) where
      n is the number of nodes in G.

    weight : None or string, optional (default=None)
      If None, edge weights are ignored.
      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.

    cutoff : bool, optional (default=None)
      If specified, only consider paths of length <= cutoff.

    Returns
    -------
    nodes : dictionary
       Dictionary of nodes with centrality as the value.

    See Also
    --------
    betweenness_centrality

    Notes
    -----
    Load centrality is slightly different than betweenness. It was originally
    introduced by [2]_. For this load algorithm see [1]_.

    References
    ----------
    .. [1] Mark E. J. Newman:
       Scientific collaboration networks. II.
       Shortest paths, weighted networks, and centrality.
       Physical Review E 64, 016132, 2001.
       http://journals.aps.org/pre/abstract/10.1103/PhysRevE.64.016132
    .. [2] Kwang-Il Goh, Byungnam Kahng and Doochul Kim
       Universal behavior of Load Distribution in Scale-Free Networks.
       Physical Review Letters 87(27):1â€“4, 2001.
       https://doi.org/10.1103/PhysRevLett.87.278701
    Nç        Fr   é   ç      ð?é   )Ú_node_betweennessÚorderÚfromkeys)ÚGÚvÚcutoffÚ
normalizedr   ÚbetweennessÚsourceÚubetweenr   ÚvkÚscales              úa/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/centrality/load.pyÚnewman_betweenness_centralityr   
   s_  € ðd 	€}ØˆØð 	?ð 	?ˆFÝ(¨¨F°F¸EÀ6ÑJÔJˆHØ¨!¨x¨-¨-˜8 Aœ;˜;¸QÑ>ˆKˆKØð 	=Ø—G’G‘I”IˆEØ˜ŠzˆzØ"Ð"Ø˜3 5¨1¡9°¸±Ñ";Ñ<Ñ<ˆKøà—k’k ! SÑ)Ô)ˆØ!ð 	0ð 	0ˆFÝ(¨¨F°F¸EÀ6ÑJÔJˆHØð 0ð 0�Ø˜B��” 8¨B¤<Ñ/��‘�ð0àð 	(Ø—G’G‘I”IˆEØ˜ŠzˆzØ"Ð"Ø˜E A™I¨%°!©)Ñ4Ñ5ˆEØ ð (ð (�Ø˜A��” %Ñ'��‘�ØÐó    Fc                 ó€  — |€t          j        | ||d¬¦  «        \  }}nt          j        | |||¦  «        \  }}d„ |                     ¦   «         D ¦   «         }|                     ¦   «          d„ |D ¦   «         |dd…<   i                      |d¦  «        }|r[|                     ¦   «         }	|	|v rAt          ||	         ¦  «        }
||	         D ]#}||k    r n||xx         ||	         |
z  z  cc<   Œ$|°[|D ]}	||	xx         dz  cc<   Œ|r8t          |¦  «        }|dk    r#d|dz
  |dz
  z  z  }|D ]}	||	xx         |z  cc<   Œ|S )	a   Node betweenness_centrality helper:

    See betweenness_centrality for what you probably want.
    This actually computes "load" and not betweenness.
    See https://networkx.lanl.gov/ticket/103

    This calculates the load of each node for paths from a single source.
    (The fraction of number of shortests paths from source that go
    through each node.)

    To get the load for a node you need to do all-pairs shortest paths.

    If weight is not None then use Dijkstra for finding shortest paths.
    NT©r   Úreturn_seenc                 ó   — g | ]	\  }}||f‘Œ
S © r    )Ú.0ÚvertÚls      r   ú
<listcomp>z%_node_betweenness.<locals>.<listcomp>l   s    € Ð8Ð8Ð8™I˜T 1ˆq�$ˆiÐ8Ð8Ð8r   c                 ó$   — g | ]\  }}|d k    ¯|‘ŒS )r   r    )r!   r#   r"   s      r   r$   z%_node_betweenness.<locals>.<listcomp>n   s!   € Ð7Ð7Ð7™)˜1˜d°°Q²°�°°°r   r   r   r
   )ÚnxÚpredecessorÚ!dijkstra_predecessor_and_distanceÚitemsÚsortr   ÚpopÚlen)r   r   r   r   r   ÚpredÚlengthÚonodesÚbetweenr   Ú	num_pathsÚxr#   r   s                 r   r   r   V   sœ  € ð  €~Ýœ¨¨6¸&ÈdÐSÑSÔS‰ˆˆvˆvåÔ=¸aÀÈÐQWÑXÔX‰ˆˆvð 9Ð8¨¯ª©¬Ð8Ñ8Ô8€FØ
‡K‚K�M„M€MØ7Ð7 vÐ7Ñ7Ô7€Fˆ1ˆ1ˆ1�Ið �kŠk˜& #Ñ&Ô&€Gà
ð 5Ø�JŠJ‰LŒLˆØ�ˆ9ˆ9Ý˜D œG™œˆIØ˜!”Wð 5ð 5�Ø˜’;�;Ø�EØ˜�
�
”
˜g aœj¨9Ñ4Ñ4�
�
‘
�
ð ð 5ð ð ð ˆØ�ˆ
ˆ
Œ
�a‰ˆ
ˆ
‰
ˆ
àð $Ý�‰LŒLˆØˆqŠ5ˆ5à˜!˜a™% A¨¡EÑ*Ñ+ˆEØð $ð $�Ø˜�
�
”
˜eÑ#�
�
‘
�
Ø€Nr   c                 óÜ   — i }|                       ¦   «         D ]\  }}d|||f<   d|||f<   Œ| D ]>}t          | ||¬¦  «        }|                     ¦   «         D ]\  }}||xx         |z  cc<   ŒŒ?|S )a¿  Compute edge load.

    WARNING: This concept of edge load has not been analysed
    or discussed outside of NetworkX that we know of.
    It is based loosely on load_centrality in the sense that
    it counts the number of shortest paths which cross each edge.
    This function is for demonstration and testing purposes.

    Parameters
    ----------
    G : graph
        A networkx graph

    cutoff : bool, optional (default=False)
        If specified, only consider paths of length <= cutoff.

    Returns
    -------
    A dict keyed by edge 2-tuple to the number of shortest paths
    which use that edge. Where more than one path is shortest
    the count is divided equally among paths.
    r	   )r   )ÚedgesÚ_edge_betweennessr)   )	r   r   r   Úur   r   r   ÚeÚ	ubetweenvs	            r   r   r   Œ   s¦   € ð0 €KØ—’‘	”	ð "ð "‰ˆˆ1Ø!ˆ�Q˜�FÑØ!ˆ�Q˜�FÑÐàð (ð (ˆÝ$ Q¨°vÐ>Ñ>Ô>ˆØ$ŸNšNÑ,Ô,ð 	(ð 	(‰LˆAˆyØ˜ˆNˆNŒN˜iÑ'ˆNˆN‰NˆNð	(àÐr   c                 ó:  — t          j        | ||d¬¦  «        \  }}d„ t          |                     ¦   «         t	          d¦  «        ¬¦  «        D ¦   «         }i }|                      |¦  «        D ]\  }}	d|||	f<   d||	|f<   Œ|r˜|                     ¦   «         }	|	|v r~t          ||	         ¦  «        }
||	         D ]`}||v rZt          ||         ¦  «        }
||         D ]<}|||fxx         ||	|f         |
z  z  cc<   |||fxx         |||	f         |
z  z  cc<   Œ=Œa|°˜|S )zEdge betweenness helper.Tr   c                 ó   — g | ]\  }}|‘ŒS r    r    )r!   ÚnÚds      r   r$   z%_edge_betweenness.<locals>.<listcomp>µ   s   € ÐFÐFÐF‘D�A�qˆaÐFÐFÐFr   r   )Úkeyr   )r&   r'   Úsortedr)   r   r4   r+   r,   )r   r   Únodesr   r-   r.   r/   r0   r6   r   r1   Úwr2   s                r   r5   r5   °   s_  € õ ”^ A v°fÈ$ÐOÑOÔO�N€Tˆ6àFÐF�F 6§<¢<¡>¤>µzÀ!±}´}ÐEÑEÔEÐFÑFÔF€Fà€GØ—’˜‘”ð ð ‰ˆˆ1Øˆ��A�‰Øˆ��A�‰ˆà
ð GØ�JŠJ‰LŒLˆØ�ˆ9ˆ9å˜D œG™œˆIØ˜!”Wð Gð G�Ø˜�9�9å # D¨¤G¡¤�IØ! !œWð Gð G˜Ø  A ˜˜œ¨7°A°q°6¬?¸YÑ+FÑF˜˜™Ø  A ˜˜œ¨7°A°q°6¬?¸YÑ+FÑF˜˜™˜øð ð Gð €Nr   )NNTN)FTN)F)NF)Ú__doc__Úoperatorr   Únetworkxr&   Ú__all__Ú_dispatchabler   r   r   r   r5   r    r   r   ú<module>rF      sÉ   ðØ Ð à Ð Ð Ð Ð Ð à Ð Ð Ð àÐ4Ð
5€ð €Ô˜XÐ&Ñ&Ô&ðHð Hð Hñ 'Ô&ðHðV0ð 0ð 0ð 0ðf 0€ð Ôð ð  ð  ñ Ôð ðFð ð ð ð ð r   