
    \MhQu                    N   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
ZddlmZmZmZ ddlmZ dgZ ej        e          ZdZd	d
dZ ed          Zi Zi Zi Zd Zd Zd Zd Zd Z  G d d          Z!d Z"d Z#ddddZ$dddZ% G d d          Z&ej'        (                    d          rje!Z)ddZ!e)j*        j+        e!_+         e j,        e)j*                  Z-e-.                    d e-j/        0                                D                       e!_1        dS dS )     N)partial)entry_points   )BackendPrioritiesConfigNetworkXConfig)argmap_dispatchableFAILED_TO_CONVERTFload_and_callc                   t          |           }i }|D ]}|j        |v r%t          j        d|j         t          d           0|rd	  |                                            ||j        <   X# t          $ r1}t          j        d|j         d| t          d           Y d}~d}~ww xY w|||j        <   |                    dd           |S )	a  
    Retrieve NetworkX ``backends`` and ``backend_info`` from the entry points.

    Parameters
    -----------
    group : str
        The entry_point to be retrieved.
    load_and_call : bool, optional
        If True, load and call the backend. Defaults to False.

    Returns
    --------
    dict
        A dictionary mapping backend names to their respective backend objects.

    Notes
    ------
    If a backend is defined more than once, a warning is issued.
    The "nx_loopback" backend is removed if it exists, as it is only available during testing.
    A warning is displayed if an error occurs while loading a backend.
    )groupz)networkx backend defined more than once:    )
stacklevelz0Error encountered when loading info for backend z: Nnx_loopback)r   namewarningswarnRuntimeWarningload	Exceptionpop)r   r   itemsrvepexcs         W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/utils/backends.py_get_backendsr   -   s#   , u%%%E	B  7b==MEBGEE    
  
	'bggiikk27   WrwWWRUWW"          BrwKKFF=$Is   $A--
B(7'B##B(znetworkx.backendsc                 j    fd|                                                      d          D             S )Nc                 @    g | ]}|                                 xS  )strip).0xx_strips     r   
<listcomp>z&_comma_sep_to_list.<locals>.<listcomp>k   s+    QQQaggii;O7QGQQQ    ,)r#   split)stringr&   s    @r   _comma_sep_to_listr,   j   s3    QQQQV\\^^11#66QQQQr(   c                  n   t                               t          dd                     t                               d t                                          t                                           z
  D                        i } t                                           D ]F\  }}d|vrt                      }n)|d         }t          |t                    st          di |}|| |<   Gt          di | } dt          |           _	        t          g g           }t          || t          t          j                            dd                    t          t          j                            d	d
                    t!          t#          t          j                            dd                                        }i t           d<   d t          j                                        D             }|j        }d|v r"t#          |                    d                    nJt#          t          j                            dt          j                            dd                              |_        t#          |                    dd                    |_        t-          |          D ]}t#          ||                   ||<   |S )a  Initialize ``config.backend_priority``, load backend_info and config.

    This gets default values from environment variables (see ``nx.config`` for details).
    This function is run at the very end of importing networkx. It is run at this time
    to avoid loading backend_info before the rest of networkx is imported in case a
    backend uses networkx for its backend_info (e.g. subclassing the Config class.)
    znetworkx.backend_infoTr   c              3      K   | ]}|i fV  	d S Nr"   )r$   backends     r   	<genexpr>z0_set_configs_from_environment.<locals>.<genexpr>x   s7        !"     r(   default_configz2All installed NetworkX backends and their configs.)algos
generatorsNETWORKX_CACHE_CONVERTED_GRAPHSNETWORKX_FALLBACK_TO_NXFNETWORKX_WARNINGS_TO_IGNORE )backend_prioritybackendscache_converted_graphsfallback_to_nxwarnings_to_ignorenetworkxc                 x    i | ]7\  }}|                     d           |dd                                         |8S )NETWORKX_BACKEND_PRIORITY_   N)
startswithlowerr$   keyvals      r   
<dictcomp>z1_set_configs_from_environment.<locals>.<dictcomp>   sS       C>>677BCC#  r(   r3   NETWORKX_BACKEND_PRIORITYNETWORKX_AUTOMATIC_BACKENDSr4   r"   )backend_infoupdater   r:   keysr   r   
isinstancetype__doc__r   r   boolosenvirongetsetr,   r9   r   r3   r4   sorted)backend_configr0   infocfgr9   config
prioritiesrE   s           r   _set_configs_from_environmentr[   n   s    &=TRRRSSS  %-]]__|7H7H7J7J%J     
 N%++-- & &4''((CC'(Cc6** $mmsmm"%w--n--N $XD (rbAAA)#JNN<dCC 
  
 BJNN+DeLLMMrz~~.KRPPQQ
 

 
 
F  "L 
((**  J
 . j   	:>>'22333JNN+
<bAA 
 
  #5Z^^LRT5U5U"V"Vj!! D D 2:c? C CMr(   c                      dS )a  This does nothing at all, yet it helps turn ``_dispatchable`` into functions.

    Use this with the ``argmap`` decorator to turn ``self`` into a function. It results
    in some small additional overhead compared to calling ``_dispatchable`` directly,
    but ``argmap`` has the property that it can stack with other ``argmap``
    decorators "for free". Being a function is better for REPRs and type-checkers.
    Nr"   r"   r(   r   _do_nothingr]      s      r(   c                     dS )NTr"   )r   argskwargss      r   _always_runra      s    4r(   c                 ,   | t           v rt           |          S | t          vrt          d|  d          t          |                                          x}t           | <   t	          |d          st
          |_        t	          |d          st
          |_        |S )N'' backend is not installedcan_run
should_run)_loaded_backendsr:   ImportErrorr   hasattrra   re   rf   )backend_namer   s     r   _load_backendrk      s    '''--8##FlFFFGGG*2<*@*E*E*G*GGB	,	'2y!! ! 
2|$$ $#Ir(   c                      e Zd ZU dZ	 ddddddddddddddZed             Zej        d             Zed	             Zdd
dZ	dd
dZ
ere
ne	Zej        ed<   d Zd Zd Zd Zd Zd Zd ZdddZddddZdddZd Zd ZdS )r
   FNGTr   graphs
edge_attrs
node_attrspreserve_edge_attrspreserve_node_attrspreserve_graph_attrspreserve_all_attrsmutates_inputreturns_graphimplemented_by_nxc                	   | t          t          |||||||	|
||          S t          |t                    rt	          d          d|j        t                              |           |j        _        |j        _        |j	        ri |j	        ddi_	        n	ddi_	        |j
        _
        |j        _        j                            |j                   |_        |j        _        d_        |_        _        |_        |_        |p|	_        |p|	_        |p|	_        |
_        |_        |>t          |t          t6          z            s!t	          dt9          |           d          d|>t          |t          t6          z            s!t	          dt9          |           d          dt          j        t:          t          z  t6          z            s&t	          dt9          j                   d	          dt          j        t:          t          z  t6          z            s&t	          d
t9          j                   d	          dt          j        t:          t<          z            s&t	          dt9          j                   d          dt          j        t:          t6          z            s&t	          dt9          j                   d          dt          j        t:                    s&t	          dt9          j                   d          dt          |t                    r|di}n\|nYt          |t6                    s!t	          dt9          |           d          dt?          |          dk    rtA          d          dt=                      _!        t=                      _"        |i _#        n'fd|$                                D             _#        d_%        fdtL          $                                D             _'        |rj'        (                    d           tR          v rtA          d           d tU          tV                              tR          <   S )a  A decorator function that is used to redirect the execution of ``func``
        function to its backend implementation.

        This decorator allows the function to dispatch to different backend
        implementations based on the input graph types, and also manages the
        extra keywords ``backend`` and ``**backend_kwargs``.
        Usage can be any of the following decorator forms:

        - ``@_dispatchable``
        - ``@_dispatchable()``
        - ``@_dispatchable(name="override_name")``
        - ``@_dispatchable(graphs="graph_var_name")``
        - ``@_dispatchable(edge_attrs="weight")``
        - ``@_dispatchable(graphs={"G": 0, "H": 1}, edge_attrs={"weight": "default"})``
            with 0 and 1 giving the position in the signature function for graph
            objects. When ``edge_attrs`` is a dict, keys are keyword names and values
            are defaults.

        Parameters
        ----------
        func : callable, optional (default: None)
            The function to be decorated. If None, ``_dispatchable`` returns a
            partial object that can be used to decorate a function later. If ``func``
            is a callable, returns a new callable object that dispatches to a backend
            function based on input graph types.

        name : str, optional (default: name of `func`)
            The name for the function as used for dispatching. If not provided,
            the name of ``func`` will be used. ``name`` is useful to avoid name
            conflicts, as all dispatched functions live in a single namespace.
            For example, ``nx.tournament.is_strongly_connected`` had a name
            conflict with the standard ``nx.is_strongly_connected``, so we used
            ``@_dispatchable(name="tournament_is_strongly_connected")``.

        graphs : str or dict or None, optional (default: "G")
            If a string, the parameter name of the graph, which must be the first
            argument of the wrapped function. If more than one graph is required
            for the function (or if the graph is not the first argument), provide
            a dict keyed by graph parameter name to the value parameter position.
            A question mark in the name indicates an optional argument.
            For example, ``@_dispatchable(graphs={"G": 0, "auxiliary?": 4})``
            indicates the 0th parameter ``G`` of the function is a required graph,
            and the 4th parameter ``auxiliary?`` is an optional graph.
            To indicate that an argument is a list of graphs, do ``"[graphs]"``.
            Use ``graphs=None``, if *no* arguments are NetworkX graphs such as for
            graph generators, readers, and conversion functions.

        edge_attrs : str or dict, optional (default: None)
            ``edge_attrs`` holds information about edge attribute arguments
            and default values for those edge attributes.
            If a string, ``edge_attrs`` holds the function argument name that
            indicates a single edge attribute to include in the converted graph.
            The default value for this attribute is 1. To indicate that an argument
            is a list of attributes (all with default value 1), use e.g. ``"[attrs]"``.
            If a dict, ``edge_attrs`` holds a dict keyed by argument names, with
            values that are either the default value or, if a string, the argument
            name that indicates the default value.
            If None, function does not use edge attributes.

        node_attrs : str or dict, optional
            Like ``edge_attrs``, but for node attributes.

        preserve_edge_attrs : bool or str or dict, optional (default: False)
            If bool, whether to preserve all edge attributes.
            If a string, the parameter name that may indicate (with ``True`` or a
            callable argument) whether all edge attributes should be preserved
            when converting graphs to a backend graph type.
            If a dict of form ``{graph_name: {attr: default}}``, indicate
            pre-determined edge attributes (and defaults) to preserve for the
            indicated input graph.

        preserve_node_attrs : bool or str or dict, optional (default: False)
            Like ``preserve_edge_attrs``, but for node attributes.

        preserve_graph_attrs : bool or set, optional (default: False)
            If bool, whether to preserve all graph attributes.
            If set, which input graph arguments to preserve graph attributes.

        preserve_all_attrs : bool, optional (default: False)
            Whether to preserve all edge, node and graph attributes.
            If True, this overrides all the other preserve_*_attrs.

        mutates_input : bool or dict, optional (default: False)
            If bool, whether the function mutates an input graph argument.
            If dict of ``{arg_name: arg_pos}``, name and position of bool arguments
            that indicate whether an input graph will be mutated, and ``arg_name``
            may begin with ``"not "`` to negate the logic (for example, ``"not copy"``
            means we mutate the input graph when the ``copy`` argument is False).
            By default, dispatching doesn't convert input graphs to a different
            backend for functions that mutate input graphs.

        returns_graph : bool, optional (default: False)
            Whether the function can return or yield a graph object. By default,
            dispatching doesn't convert input graphs to a different backend for
            functions that return graphs.

        implemented_by_nx : bool, optional (default: True)
            Whether the function is implemented by NetworkX. If it is not, then the
            function is included in NetworkX only as an API to dispatch to backends.
            Default is True.
        Nrn   z-'name' and 'graphs' must be passed by keywordr0   zBad type for edge_attrs: z. Expected str or dict.zBad type for node_attrs: z"Bad type for preserve_edge_attrs: z. Expected bool, str, or dict.z"Bad type for preserve_node_attrs: z#Bad type for preserve_graph_attrs: z. Expected bool or set.zBad type for mutates_input: z. Expected bool or dict.zBad type for returns_graph: z. Expected bool.r   zBad type for graphs: z0'graphs' must contain at least one variable namec                     i | ]h\  }}|d          xdk    r&j                             |dd          x          pn-dk    r&j                            |dd          x          pn||iS )?N]r   )optional_graphsaddlist_graphs)r$   kvlastselfrF   s      r   rG   z)_dispatchable.__new__.<locals>.<dictcomp>  s        Aq	 bEMDc)) $((#2#77>3 3;; %))1R4.#99@S  r(   c                 6    h | ]\  }}d |v 	|d          v |S )	functionsr"   )r$   r0   rW   r   s      r   	<setcomp>z(_dispatchable.__new__.<locals>.<setcomp>  sA     
 
 
d""ttK/@'@'@ '@'@'@r(   r>   z/Algorithm already exists in dispatch registry: ),r   r
   rM   str	TypeError__name__object__new____defaults____kwdefaults__
__module____qualname____dict__rK   __wrapped__rO   	_orig_doc_cached_doc	orig_funcr   rp   rq   rr   rs   rt   rv   _returns_graphdictrN   rP   rT   lenKeyErrorr~   r   ro   r   _sigrJ   r:   r   _registered_algorithmsr	   r]   )clsfuncr   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   r   r   rF   s     `          @@@r   r   z_dispatchable.__new__   sG   j <%%$7$7%9#5++"3    dC   	WKLLRVV<=D~~c""  - 	4"JT%8"J)T"J"JD#,d"3D/ -T]+++ 	$$#6#L:L #6#L:L $8$N<N!*+!*Zt*L*L!UD,<,<UUU  !*Zt*L*L!UD,<,<UUU  $2D3J4EFF 	0T$:R5S5S 0 0 0   $2D3J4EFF 	0T$:R5S5S 0 0 0   $3TCZ@@ 	)d4;T6U6U ) ) )   $,dTk:: 	*tD4F/G/G * * *   $-t44 	"tD4G/H/H " " "  
 fc"" 		Ya[FF^FD)) 	YMVMMM  [[AMNNTXX  #uu55>DKK      #LLNN  DK 	
 
 
 
!-!3!3!5!5
 
 

  	*Mj))))))H$HH  #vk""4(('+t$r(   c                 N    | j         }||                                 x}| _         |S )zIf the cached documentation exists, it is returned.
        Otherwise, the documentation is generated using _make_doc() method,
        cached, and then returned.)r   	_make_doc)r   r   s     r   rO   z_dispatchable.__doc__  s-     :$(NN$4$44B!	r(   c                 "    || _         d| _        dS )z_Sets the original documentation to the given value and resets the
        cached documentation.N)r   r   )r   rF   s     r   rO   z_dispatchable.__doc__  s    
 r(   c                 l   | j         &t          j        | j                  }t	          d |j                                        D                       sz|                    g |j                                        t          j        dt          j        j	        d          t          j        dt          j        j
                            }n\|j                                        ^ }}|                    g |t          j        dt          j        j	        d          |          }|| _         | j         S )zzReturn the signature of the original function, with the addition of
        the `backend` and `backend_kwargs` parameters.Nc              3   J   K   | ]}|j         t          j        j        k    V  d S r/   )kindinspect	ParameterVAR_KEYWORD)r$   ps     r   r1   z._dispatchable.__signature__.<locals>.<genexpr>  s@        <='+77     r(   r0   )defaultbackend_kwargs
parameters)r   r   	signaturer   anyr   valuesreplacer   KEYWORD_ONLYr   )r   sigr   var_keywords       r   __signature__z_dispatchable.__signature__  s]   
 9#DN33C   ADAVAVAXAX      kk ..00 )%w'8'Et   
  ),g.?.K   " 
 
 ,/>+@+@+B+B([kk # )%w'8'Et   
 $  "   DIyr(   )r0   c                   ||dk    rt          d| d          d| j        vrt          d| j         d           | j        |i |S )zDReturns the result of the original function (no backends installed).Nr>   rc   rd   zz' is not implemented by 'networkx' backend. This function is included in NetworkX as an API to dispatch to other backends.)rh   r:   NotImplementedErrorr   r   )r   r0   r_   r`   s       r   _call_if_no_backends_installedz,_dispatchable._call_if_no_backends_installed  s|    7j#8#8E'EEEFFFT]**%"DI " " "  
 t~t.v...r(   c                   |}||t           vrt          d| d          i } j                                        D ]\  }}|t	          |          k     r&||v rt           j         d|          ||         }n0||v r	||         }n#| j        vrt           j         d|           n|$| j        vrt           j         d|d          |||<    j        rt          |          } j        |
                                z  D ]6}t          ||                   }	|	||<   ||v r|	||<   &|	| j        |         <   7 fd|                                D             }
 j        |
                                z  D ]'}|
                    d	 ||         D                        (nd
 |                                D             }
t          j        j                             j         j        rt          j        j        j        nt          j        j        j                  }t          j        j        od j        v } j        r#|r!|                     |d         |||          S |
                    d           |d| d}d| d j         d| }|
r|
|hk    rj                     |||          r                     ||||          S                      |          rd}nd}t9          d j         d| d| d|                                ||
          rʉ                     |||          ry                     ||          r$t>                               d j        |           g }nd} !                    ||
||||          }|r|D ]\  }}|"                    |d           |S                      |          rd}nd}t9          d j         d| d| d|           t	          |
          dk    r#d}dtG          tI          |
                     d}
nd}t          d j         d| d|
 d| d| d |                                ||          rd!}d"}t	          |
          dk    r-|
\  }d#| d$ j         d%| }	                      |||          r                     ||||d&z            S 	 |rOtK          d' |                                D                       r$t>                               d(| j        |           n                      |          rd&}nd}t9          ||z            # t8          $ rZ}tK          d) |                                D                       r$t>                               d*| j        ||           n Y d}~nud}~ww xY w|rNtK          d+ |                                D                       r#t>                               d, j        |
|           ntM          d j         d-|
 d.|             j'        |i |S |s|
sdg}ng }tQ                      }g }g }|D ]K}||v r|)                    |           ||
v r|*                    |           6|*                    |           Lg }g }|D ]K}||v r|)                    |           ||
v r|*                    |           6|*                    |           L|
|z
  } t	          |           dk    r#t>                               d/ j        |            d0} t          tW          j,        ||| ||                    }!t	          |!          dk    r$t>                               d1 j        |
pd2|!           g }"t[          |!          D ]=\  }#}|#rt>                               d3|           	 |
r|
|hk    r1                     |||          r                     |||          c S n                     ||
          r                     |||          rx .                    |||          rL !                    ||
||          } j        r)|
r'||
vr#t>                               d4 j        |
||           |c S |"*                    |           # t8          $ r-}t>                               d5| j        |           Y d}~7d}~ww xY w|"D ]}t>                               d6|           	  !                    ||
||          } j        r)|
r'||
vr#t>                               d4 j        |
||           |c S # t8          $ r,}t>                               d5| j        |           Y d}~d}~ww xY wt	          |
|z
  x}$          dk    r!t          d7|
 d8 j         d9|! d:|$ d;	          d j        vrd<}nd}t9          d j         d=|! d>|           )?zReturns the result of the original function, or the backend function if
        the backend is specified and that backend implements `func`.Nrc   rd   z() got multiple values for z$() missing required graph argument: z() required graph argument z is None; must be a graphc                 J    h | ]\  }}|j         vt          |d d           S __networkx_backend__N)r   getattr)r$   gnamegr   s      r   r   z@_dispatchable._call_if_any_backends_installed.<locals>.<setcomp>M  sB     # # #E1 000 1488000r(   c              3   8   K   | ]}t          |d d          V  dS r   r   r$   r   s     r   r1   z@_dispatchable._call_if_any_backends_installed.<locals>.<genexpr>S  sC       + + A5t<<+ + + + + +r(   c                 0    h | ]}t          |d d          S r   r   r   s     r   r   z@_dispatchable._call_if_any_backends_installed.<locals>.<setcomp>X  s5     # # # 1488# # #r(   r>   r   r<   zZNo other backends will be attempted, because the backend was specified with the `backend='z'` keyword argument.z3' backend raised NotImplementedError when calling 'z'. extra_messagez for the given argumentsr8   z' is not implemented by 'z	' backendz. z'%s' will mutate an input graph. This prevents automatic conversion to, and use of, backends listed in `nx.config.backend_priority`. Using backend specified by the `backend='%s'` keyword argument. This may change behavior by not mutating inputs.r   	mutationsr   sz)' is unable to convert graph from backend z to 'z2' backend, which was specified with the `backend='z'` keyword argument. zconversions between backends (if configured) will not be attempted because the original input graph would not be mutated. Using the backend keyword e.g. `backend='some_backend'` will force conversions and not mutate the original input graph.zThis call will mutate inputs, so fall back to 'networkx' backend (without converting) since all input graphs are instances of nx.Graph and are hopefully compatible.z	Backend 'z' does not implement 'z2'%s. This call will mutate an input, so automatic z with these argumentsc              3   J   K   | ]}t          |t          j                  V  d S r/   rM   nxGraphr   s     r   r1   z@_dispatchable._call_if_any_backends_installed.<locals>.<genexpr>  sD       . .  #1bh//. . . . . .r(   zBackend '%s' can't run '%s'. %sc              3   J   K   | ]}t          |t          j                  V  d S r/   r   r   s     r   r1   z@_dispatchable._call_if_any_backends_installed.<locals>.<genexpr>  s.      UUq:a22UUUUUUr(   z-Backend '%s' raised when calling '%s': %s. %sc              3   J   K   | ]}t          |t          j                  V  d S r/   r   r   s     r   r1   z@_dispatchable._call_if_any_backends_installed.<locals>.<genexpr>  sD       ( (  1bh''( ( ( ( ( (r(   z:'%s' was called with inputs from multiple backends: %s. %szN' will mutate an input, but it was called with inputs from multiple backends: z. Automatic zCall to '%s' has inputs from multiple backends, %s, that have no priority set in `nx.config.backend_priority`, so automatic conversions to these backends will not be attempted.r"   zaCall to '%s' has inputs from %s backends, and will try to use backends in the following order: %snozTrying next backend: '%s'zCall to '%s' is returning a graph from a different backend! It has inputs from %s backends, but ran with '%s' backend and is returning graph from '%s' backend)Backend '%s' raised when calling '%s': %sz2Trying backend: '%s' (ignoring `should_run=False`)zUnable to convert inputs from z backends and run 'z6'. NetworkX is configured to automatically convert to zB backends. To remedy this, you may enable automatic conversion to z backends by adding them to `nx.config.backend_priority`, or you may specify a backend to use with the `backend=` keyword argument.zO This function is included in NetworkX as an API to dispatch to other backends.z' is not implemented by z backends. To remedy this, you may enable automatic conversion to more backends (including 'networkx') by adding them to `nx.config.backend_priority`, or you may specify a backend to use with the `backend=` keyword argument.)/rJ   rh   ro   r   r   r   r   r~   r   listrL   rK   r   r   rY   r9   rS   r   r4   r3   r<   r:   _is_testing_convert_and_call_for_testsdiscard_can_backend_run_call_with_backend_does_backend_haver   _can_convert_will_call_mutate_input_loggerdebug_convert_and_callr   nextiterallRuntimeErrorr   rT   r   append	itertoolschain	enumerate_should_backend_run)%r   r0   r_   r`   rj   graphs_resolvedr   posgraphlist_of_graphsgraph_backend_namesr9   r<   backend_kwarg_msgr   extrar   r   cacherE   maybe_s
mutate_msgfallback_msgmsg_templater   backend_fallbackseengroup1group2r   group4group5group3	try_orderbackends_to_try_againis_not_firstunspecified_backendss%   `                                    r   _call_if_any_backends_installedz-_dispatchable._call_if_any_backends_installed  s    #L(H(HJ,JJJKKK+++-- 	/ 	/JE3SYYF??#ty$V$VU$V$VWWWS	&ud222yMMeMM   } 444#9ccccc   5
 */&&  	::D)O,@,@,B,BB > >!%oe&<!=!=)7&F??$2F5MM/=DU+,,# # # # / 5 5 7 7# # #
 )O,@,@,B,BB  #** + +,U3+ + +    # #(//11# # #
 9599I"2BI&11+1	
 
 1QjDM6Q 	 0 	\5I 33 #-	 4    	##D)))#
S0<S S S 
6L 6 6I6 6"36 6  ' *=,*O*O((tVDD 22$dF- 3    **<88 6EEE)4	 4 4L 4 44 4 14 4     /BCC %((tVDD 33D&AA )/
 !I(   %'		$(	//$+&3"+ 0  B ! 1*3 1 1JE3 "IIc40000I**<88 6EEE)4	 4 4L 4 44 4 14 4   &''1,,&L$t4G/H/H*I*I&L&L&L##'DI ' ' ' '&' '-9' '0<' ' %' '   ''f55 ]	3; F 
 &''1,,!4Q Q QDI Q QDNQ Q 
&H,,\4HH #66( "*69P*P	  7     & & H# . . "1!7!7!9!9	. . . + + H  =( I(	     22<@@ '$;EE$&E1,2FGGG= + 
 
 
UUO<R<R<T<TUUUUU 	K( I(        
>   C ( ( )//11	( ( ( % %  PI' 	    #.	 . .6I. .!+. .   "4>426222  	"!4 	" !+|!x uu$ 	$ 	$Dt||HHTNNN***d####d####$ 	$ 	$Dt||HHTNNN***d####d####$t+v;;??" MM8 	   FPPQQ	y>>A MM6	#+t   !#*3I*>*> ,	 ,	&L, I9<HHH)* !?.Al^.S.S,,\4HH S#66|T6RRRRRS&& "5  ?++L$GG? //dFKK "!33(*=tV  !/ 3 !-4G G G $MM!X !%	 3 , ,    "			)00>>>&   ? I	        2 	 	LMMDl  ++ "5tV  '+ %,???MMP 	+$$   			&   ? I	        ':T'AA#BBQFFU1D U U	U UU U "6U U U   T]**" E
 E!7	 7 79 7 7 05	7 7
 
 	
sW   2T6 6
V AVV6b Bb )b  
b7
"b22b7A	d&&
e0"ee__call__c                     t          | j        x}t                    r|S t                    t	          fd|                                D                       S )Nc              3      K   | ]n\  }}|                     d           s%|k    r|         n                    |          dun,|k    r|         n                    |dd         d           V  odS )znot N   T)rB   rS   )r$   arg_namearg_posr_   r`   ns      r   r1   z8_dispatchable._will_call_mutate_input.<locals>.<genexpr>  s       
 

 "' &&v..Xa'kkT']]vzz(/C/CDPP ()7{{d7mm

8ABB<QU8V8VW	
 
 
 
 
 
r(   )rM   rv   rP   r   r   r   )r   r_   r`   rv   r  s    `` @r   r   z%_dispatchable._will_call_mutate_input
  s     (::}TBB 	!   II 
 
 
 
 
 

 &3%8%8%:%:
 
 
 
 
 	
r(   c                 |    |dk    p|                     d|h          }|st                              d||           |S )Nr>   z2Unable to convert from %s backends to '%s' backend)issubsetr   r   )r   rj   r   r   s       r   r   z_dispatchable._can_convert#  s^     Z' 
+>+G+G&,
 ,
  	MMD#  
 	r(   c                 h    |dk    r	d| j         v S t          |          }t          || j                  S )z/Does the specified backend have this algorithm?r>   )r:   rk   ri   r   )r   rj   r0   s      r   r   z _dispatchable._does_backend_have1  s9    :%%..--w	***r(   c           
         |dk    r	d| j         v S t          |          }t          || j                  s#t                              d|| j                   dS |                    | j        ||          }t          |t                    s|sPt          |t                    rd| nd}t                              d|| j        t          | ||          |           dS dS )zBCan the specified backend run this algorithm with these arguments?r>   z$Backend '%s' does not implement '%s'F, because: r8   z0Backend '%s' can't run `%s` with arguments: %s%sT)
r:   rk   ri   r   r   r   re   rM   r   _LazyArgsRepr)r   rj   r_   r`   r0   re   reasons          r   r   z_dispatchable._can_backend_run9  s    :%%..-- w	** 	MM6di   5//$)T6::gs## 		7 		0:7C0H0HP,7,,,bFMMB	dD&11   5tr(   c           
      :   |dk    rdS t          |          }|                    | j        ||          }t          |t                    s|sPt          |t                    rd| nd}t
                              d|| j        t          | ||          |           dS dS )zShould the specified backend run this algorithm with these arguments?

        Note that this does not check ``backend.can_run``.
        r>   Tr	  r8   z4Backend '%s' shouldn't run `%s` with arguments: %s%sF)rk   rf   r   rM   r   r   r   r
  )r   rj   r_   r`   r0   rf   r  s          r   r   z!_dispatchable._should_backend_runR  s     :%%4--''	4@@
j#&& 		j 		3=j#3N3NV/:///TVFMMF	dD&11   5tr(   c                V	      j         j        |i |                                  j        sj        }|d= j        |fS dk    rdxxn# j         j         j         j	         j
        du rndu rdnt          t                    rxj                 du st          j                           rddnJj                 du r9t          t                    rk    st          t                    r	v rddndnt          t                    r̉d         dk    r/t                              j        dd	                  d          nt          j                           rddnj                 j                 dinv j        d
k    rGt%          j        d         d          r,t                              j        d         j        d          n$dn!fd                                D             du rndu rdnt          t                    rxj                 du st          j                           rddnJj                 du r9t          t                    rk    st          t                    r	v rddndnt          t                    ryd         dk    r.t                              j        dd	                            n`t          j                           rddnAj                 j                 din$dn!fd                                D              j        D ]' j        v r+ f
dj                 D             j        <   7j                 }|% j        v rPt/          d d j         d          t          t                    rd}                              }	n}}	t          t                    rd}
                              }n}
}t          t2                    rv }n}t5          |dd          k    r'                     ||	|||
|
  
        j        <   )j        }|d= j        |fS )z~Convert graph arguments to the specified backend.

        Returns
        -------
        args tuple and kwargs dict
        r0   r>   TFNr   [r   r{   to_numpy_arraydtypenamesc                     i | ]G\  }}j         |         xt          |t                    rj                             |d          n|HS )Nr   	argumentsrM   r   rS   )r$   rE   rF   bound	edge_attrs      r   rG   z4_dispatchable._convert_arguments.<locals>.<dictcomp>  sb       C!&!55IB *S#:N:NW5?..sA666TWBBBr(   c                     i | ]F\  }}j         |         xt          |t                    rj                             |          n|GS r/   r  )r$   rE   rF   r  	node_attrs      r   rG   z4_dispatchable._convert_arguments.<locals>.<dictcomp>  s`       C!&!55IB z#s7K7KT5?..s333QTBBBr(   c                 |   
 g | ]8}t          |d d          k    r
                    |	
  
        n|9S )r   r>   rp   rq   rr   rs   rt   
graph_name	use_cacher   )r   _convert_graph)r$   r   rj   rp   r   r   rq   rr   rt   rs   r   r  s     r   r'   z4_dispatchable._convert_arguments.<locals>.<listcomp>  s     * * *  q"8*EEUU ''$#-#-,?,?-A#("+"+ (    * * *r(   z!Missing required graph argument `z` in z	 functionr   r  )r   bindapply_defaultsro   r`   r_   rr   rs   rt   rp   rq   rM   r   r  callabler   fromkeysr   ri   r  r   r   r~   r   rS   rT   r   r  )r   rj   r_   r`   r  r   bound_kwargsr   preserve_edgesedgespreserve_nodesnodespreserve_graphr  r  rp   r   r  rq   rr   rt   rs   s   ``  ``       @@@@@@@@@r   _convert_argumentsz _dispatchable._convert_argumentsj  s=    ("'888{ 	, <LY':|++:%%OSSS"58L8L"&":"&":#'#< JJ %'' D((JJ+S11 	,23t;;x 34@ @;
 '+#!

!45>>:s++ ?"555j$// 6':55
 ',#!

 ',# 
C(( 	!}## "]]5?:ad;K+LaPP

%/*566 "&*#!

,8#oj91=

...7('4 4. "]]5?7+C+I1MM

 "

     * 0 0 2 2  J %'' D((JJ+S11 	,23t;;x 34@ @;
 '+#!

!45>>:s++ ?"555j$// 6':55
 ',#!

 ',# 
C(( 	!}## "]]5?:ad;K+LMM

%/*566 	"&*#!

,8#oj94@

 "

     * 0 0 2 2  J [ 7	 7	E(((* * * * * * * * * * * * * #_U3* * *&&$ .= 444 #\E\\	\\\   1488 '%*N/33E:FFEE%8N&E1488 '%*N/33E:FFEE%8N&E2C88 :%*.B%BNN%9N5"8*EEUU-1-@-@$#(#(,:,:-;#("+"+ .A . .EOE* |#z<''r(   c          
      V   |	rt          |dd           nd }||                    di                               |i           }t          |||||          }t          |||
          \  }}|dt          j        j        vr t          j        d|d| j	         d           |t          k    rt          d	| d
| j	         d          t                              dt          |dd           || j	        |           |S |dk    rt          |d          s$t                              d| j	        ||           |S t          |j                  }	 |                    |          }n# t$          $ r |t'          ||t                      w xY wt          |          }	 |                    ||||||p|d u| j	        |          }n'# t$          $ r |t'          ||t                      w xY w|Ct'          |||           t                              dt          |dd           || j	        |           |S )N__networkx_cache__r:   rp   rq   rr   rs   rt   )r   r   zNote: conversions to backend graphs are saved to cache (`G.__networkx_cache__` on the original graph) by default.

This warning means the cached graph is being used for the z backend in the call to a  .

For the cache to be consistent (i.e., correct), the input graph must not have been manually mutated since the cached graph was created. Examples of manually mutating the graph data structures resulting in an inconsistent cache include:

    >>> G[u][v][key] = val

and

    >>> for u, v, d in G.edges(data=True):
    ...     d[key] = val

Using methods such as `G.add_edge(u, v, weight=val)` will correctly clear the cache to keep it consistent. You may also use `G.__networkx_cache__.clear()` to manually clear the cache, or set `G.__networkx_cache__` to None to disable caching for G. Enable or disable caching globally via `nx.config.cache_converted_graphs` config.

To disable this warning:

    >>> nx.config.warnings_to_ignore.add("cache")
z6Graph conversion aborted: unable to convert graph to 'z' backend in call to `z1', because this conversion has previously failed.zZUsing cached converted graph (from '%s' to '%s' backend) in call to '%s' for '%s' argumentr   r>   zUnable to convert input to 'networkx' backend in call to '%s' for '%s argument, because it is not from a backend (i.e., it does not have `G.__networkx_backend__` attribute). Using the original object: %s)rp   rq   rr   rs   rt   r   r  zUCaching converted graph (from '%s' to '%s' backend) in call to '%s' for '%s' argument)r   
setdefault_get_cache_key_get_from_cacher   rY   r=   r   r   r   r   r   r   r   ri   rk   r   convert_to_nxr   _set_to_cacheconvert_from_nx)r   rj   r   rp   rq   rr   rs   rt   r  r  r   nx_cacher   rE   
compat_keyr   r0   s                    r   r  z_dispatchable._convert_graph7  s	    BKT75"6===PT''
B77BB<QSTTE %%$7$7%9  C -UC9MMMNJ~")">>>MN $0N N $(9	N N N  . ***
 .I(I I@D	I I I  
 8E#94@@ I   	:%% 5"899 ! I   #E$>??G**511   '!%.?@@@
 $L11G,,))(;(; *>)UQUAU) -      '!%.?@@@ %b)))MM45t<<	   	s   	E $F&F= =$G!r   c          
      n   |dk    r | j         |i |S t          |          }t                              d|| j        t          | ||                     	  t          || j                  |i |S # t          $ r:}|2t                              d|| j        |           t          |          | d}~ww xY w)zICall this dispatchable function with a backend without converting inputs.r>   6Using backend '%s' for call to '%s' with arguments: %sNr   )r   rk   r   r   r   r
  r   r   )r   rj   r_   r`   r   r0   r   s          r   r   z _dispatchable._call_with_backend  s    :%%!4>426222--DI$f--		
 	
 	
	.77DI..????" 		 		 		(? I	   *-88cA		s   A0 0
B4:5B//B4r   c          
      H   |dk    r| j         }n$t          |          }t          || j                  }||hz
  }	t                              dt          |	          dk    r|	ndt          t          |	                     dt          |	          dk    rdnd|| j                   	 | 	                    |||t          j        j        |          \  }
}nK# t          $ r>}t	          j        d|dnd
z   ||| j        g|dn|fR   |t          |          | d	}~ww xY w|dk    r1t                              d|| j        t          | |
|                     	  ||
i |S # t          $ r:}|2t                              d|| j        |           t          |          | d	}~ww xY w)a  Call this dispatchable function with a backend after converting inputs.

        Parameters
        ----------
        backend_name : str
        input_backend_names : set[str]
        args : arguments tuple
        kwargs : keywords dict
        extra_message : str, optional
            Additional message to log if NotImplementedError is raised by backend.
        mutations : list, optional
            Used to clear objects gotten from cache if inputs will be mutated.
        r>   zJConverting input graphs from %s backend%s to '%s' backend for call to '%s'r   rc   r   r8   r  r   zAFailed to convert graphs from %s to '%s' backend for call to '%s'Nz: %sr"   r5  r   )r   rk   r   r   r   r   r   r   r   r(  r   rY   r;   r   r
  )r   rj   input_backend_namesr_   r`   r   r   r   r0   other_backend_namesconverted_argsconverted_kwargsr   s                r   r   z_dispatchable._convert_and_call  s8   . :%%>DD#L11G7DI..D1\NBX&''!++  7T$23344777*++a//CCRI	
 	
 	
	/3/F/F):# 0G 0 0,N,, # 	 	 	 MS&.22F<#	 &-""C6    ()-88cA	 :%%MMH	dN4DEE	  	4<+;<<<" 		 		 		(? I	   *-88cA		s0   %,C 
D9DDE 
F!'5FF!r   c                <    !"#$%&'()*+,- t          |          }                     |||          s|s j        s@|r1t                              d| j        t           ||                       j        |i |S ddl}d j         d| }t          | j                  r|dz  }|
                    |           ddlm m!m" ddlm(m) dd	lmmm%m& dd
lm, ddlm# ddl*ddlmm$ ddlm+  j         od j!        v o j        dv}d j!        v o "                    ||          }	|r|s|	s|x}
}n"tG          !#$%&(),fd|D              \  }
}|r|s|	s|x}}nStG          !#$%&(),-fd|$                                D              \  }}tK          |          }tK          |          }	  &                    ||
|dd          \  }}n# tN          $ r}|r3t                              d| j                     j        |i |cY d}~S ddl}|
                    |j(        r|j(        d         n j         dtS          |          j*                    Y d}~nd}~ww xY w|	r  j+        j,        |i |}|-                                   j+        j,        |i |}|-                                  j        D ]@}|j.        |         }|j.        |         |cxu rn $|                                |j.        |<   A|j(        }|j/        }|0                    dd           t                              d| j        t           ||                     	  tc          | j                  |i |}n# tN          $ r}|r4t                              d| j        |             j        |i |cY d}~S ddl}|
                    |j(        r|j(        d         n j         dtS          |          j*                    Y d}~nd}~ww xY w j         te          |tf          j4                  pEt          |d          p5te          |tj          tl          z            oto          d |D                       k    rd j        dv rto          d |D                       sB j        dv rto          d |D                       s  j        dvrtq          d  j                   d* !"'* +fd!	'' fd"} j        d#v rnqte          |!          r ||          }nU	  '|           n=# tp          $ r0}tq           j         d$| d%tS          |           d&          |d}~ww xY w '|           d+d(}|	rX  j        |i |} j        D ]C}|j.        |         }|j.        |         }||#|9                    |          } |||d)           D|9                    |          }|r:te          |tf          j4                  r |	r|}n  j        |i |} |||           |S |S ),zECall this dispatchable function with a backend; for use with testing.zZFalling back to use 'networkx' instead of '%s' backend for call to '%s' with arguments: %sr   Nrc   z' not implemented by z with the given arguments)IterableIteratorMapping)copydeepcopy)BufferedReaderBytesIOStringIOTextIOWrapper)tee)Random)	GeneratorRandomState)sparrayr>   >   read_gml	read_gexf
from_pydot
read_pajekread_graph6read_adjlistread_graphmlread_sparse6read_edgelistpydot_read_dotquotient_graphagraph_read_dotread_multiline_adjlistbipartite_read_edgelistc              3     K   | ]y}t          |          r| |          fnWt          |z  z  z            r| 
|          fn1t          |          rt          |	z            s |          n||fV  zd S r/   rM   )r$   argrB  rC  rH  r>  rG  rI  rD  rE  r@  rA  rF  s     r   r1   z<_dispatchable._convert_and_call_for_tests.<locals>.<genexpr>b  s       
 
  "#{33$S((3--(( "#w'9F'BY'NOO$#ttCyy)) "#x00$&sN],JKK$S s
 
 
 
 
 
r(   c              3   H  K   | ]\  }}t          |          r||f| |          ffnst          |	z  z  z            r||f| |          ffnIt          |          r2t          |
z            s| |          xd          f|d         ffn||f||ffV  dS )r   r   NrZ  )r$   r   r   rB  rC  rH  r>  rG  rI  rD  rE  r@  rA  rF  teeds      r   r1   z<_dispatchable._convert_and_call_for_tests.<locals>.<genexpr>r  s	      
 
 1 "![11*aVa!-.. "!Wx%7&%@9%LMM*1a&1dd1gg,// "!X..*&q.=*HII*1ss1vv~tq12QQLAA a&1a&)
 
 
 
 
 
r(   Fr7  z`Graph conversion failed; falling back to use 'networkx' instead of '%s' backend for call to '%s'z raised r0   r5  zRBackend '%s' raised when calling '%s': %s; falling back to use 'networkx' instead.r   c              3   j   K   | ].}t          |t          j                  pt          |d           V  /dS r   )rM   r   r   ri   r$   r%   s     r   r1   z<_dispatchable._convert_and_call_for_tests.<locals>.<genexpr>  sR         q"(++Qwq:P/Q/Q     r(   >   check_planaritycheck_planarity_recursivec              3      K   | ]}|d u V  	d S r/   r"   r_  s     r   r1   z<_dispatchable._convert_and_call_for_tests.<locals>.<genexpr>  s&      22aT	222222r(   >   held_karp_ascentc              3   @   K   | ]}t          |t                    V  d S r/   )rM   r   r_  s     r   r1   z<_dispatchable._convert_and_call_for_tests.<locals>.<genexpr>  s,      <<
1d++<<<<<<r(   >   
all_triadsnonisomorphic_treesgeneral_k_edge_subgraphsz!`returns_graph` is incorrect for c           
      `   t          | j                  r-t          j         d|  dt	          |            d| d          t          | j        	z            rd S t          | t          j                  r, | j        |dz               | j	        |dz              d S t          |           rt          t          |           r*t          | t                    s| D ]} ||dz              t          |           r'|                                 D ]} ||dz              d S d S )N returned a numpy scalar  (z, depth=)r   )depth)rM   numberr   r   rN   ndarrayr   r   _node_adjr   r   r   )
rF   rl  r%   r=  r>  r?  check_resultnpr   rJ  s
      r   rq  z?_dispatchable._convert_and_call_for_tests.<locals>.check_result  s   #ry)) "y]]3]]$s))]]UZ]]]   #rzG344 #rx(( SYeai8888SXUQY7777#x(( *))#x(( 5C1E1E 5 5 5A L%!)44444#w'' 5 5 5A L%!)444445 55 5r(   c              3      K   | D ]P}	  |           n=# t           $ r0}t          j         d| dt          |           d          |d }~ww xY w|V  Qd S )Nri  rj  rk  )r   r   rN   )itrF   r   rq  r   s      r   check_iteratorzA_dispatchable._convert_and_call_for_tests.<locals>.check_iterator  s         L%%%%#   &9RRsRRd3iiRRR  				 s   
A+A

A>   from_edgelistri  rj  rk  Tc                 n   |                                  |                                 k    sJ |                                 |                                k    sJ |                                 |                                u sJ |                                 |                                u sJ |r8| j        |j        k    sJ | j        |j        k    sJ | j        |j        k    sJ d S t          |           t          |          k    sJ t          | j                  t          |j                  k    sJ d S r/   )	number_of_nodesnumber_of_edgesis_directedis_multigraphr   ro  rp  rT   r$  )G1G2stricts      r   assert_graphs_equalzF_dispatchable._convert_and_call_for_tests.<locals>.assert_graphs_equal  s3   %%''2+=+=+?+?????%%''2+=+=+?+?????>>##r~~'7'77777##%%)9)9););;;;; 6x28++++x28++++w"'))))))2ww#b''))))28}}BH555555r(   )r~  )r   T):rk   r   ro   r   r   r   r
  r   pytestri   xfailcollections.abcr=  r>  r?  r@  rA  iorB  rC  rD  rE  r   rF  randomrG  numpynumpy.randomrH  rI  scipy.sparserJ  r   r:   r   zipr   r   r(  r   r_   rN   r   r   r  r  r  r`   r   r   rM   r   r   tupler   r   r   r/  ).r   rj   r_   r`   r<   r0   r  msgcompare_result_to_nxcompare_inputs_to_nxargs_to_convertargs_nxkwargs_to_convert	kwargs_nxr:  r;  r   bound_backendbound_nxr   graph_nxresultru  r  	result_nxG0r|  converted_resultrm   rB  rC  rH  r=  r>  r?  rG  rI  rD  rE  rq  r@  rA  rr  rJ  rF  r]  s.   `                            @@@@@@@@@@@@@@@@@r   r   z)_dispatchable._convert_and_call_for_tests  s	     --$$\4@@ 	 	7T[ 	7! MM>$	%dD&99   &t~t6v666MMMDdiDDlDDCw	** 322LL??????????''''''''GGGGGGGGGGGG!!!!!!!!!!!!77777777((((((
  dm+	 	4 $-'VD,H,Hv,V,V 	
  	/ 	8L 	(,,Ogg'*
 
 
 
 
 
 
 
 
 
 
 
 
 
  $
 
 
($OW  	(1 	(:N 	(,22		+.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 !'
 
 
,(y !%%6 7 7YI	/3/F/F! 0G 0 0,N,, # 	 	 	 =7 I	   &t~w<)<<<<<<<<MMMLL"xW	-W-W499CU-W-W       	   	+3D.3^XGWXXM((***.t).E9EEH##%%% @ @#-e4 *51XIIIIIIII08H&u-mG IMM)T***DI$0@AA		
 	
 	
	0WWdi00.UDTUUFF" 	 	 	 => I   &t~w<)<<<<<<<<MMMLL"xW	-W-W499CU-W-W       	( 628,, 6#9::fedl33   #    	 	 	MMM22622222 N
 	111<<V<<<<< 2 	  N49NNOOO	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5(	 	 	 	 	 	 9))))) 		!#^F++FFV$$$$   "yTT6TTT&\\TTT  L   	6 	6 	6 	6   	>&=9==I > >",U3'.>R^ ..r22B''Bu===="0088 		J/?$J$J 		 $ :"DNG9y99#3444Hsb   G   
I2*/I-I2A	I--I2!M= =
P0P7P=A	PPT% %
U/+UUc                 l   | j         dhk    r| j        S ddg}t          | j         dhz
            D ]}t          |         }d|v r!|                    | d|d                     n|                    |           d|vs| j        |d         vr|                    d           s|d         | j                 }|                    d          p|                    d	          x}r5|                    d
 |                    d          D                        d}nd}|                    d          p|                    d          x}r|r|                    d           |                    d           t          |          D ]Q}|                    d|            ||         x}	r|                    d|	            |                    d           Rn|                    d           |                    d          x}
r.|                    d|
 d           |                    d           | j        pd}|	                                sd| j         d}| j         rB|
                                 d                    |          }|	                                 d| }d| j         vr|                    d          }d}||                                         s|dz  }||                                         |t          |          k     rL||                                         r2|dz  }|t          |          k     r||                                         2t          | j                   }t          |          dk    rd}nt          |          dk    rd|d          d}n`t          |          dk    rd|d          d|d          d}n7d d!                    d" |d#d$         D                       z   d%|d$          dz   }d&| d'}|                    ||           d                    |          }|S )(zGenerate the backends section at the end for functions having an alternate
        backend implementation(s) using the `backend_info` entry-point.r>   Backendsz--------short_summaryz : r   r8   additional_docsextra_docstringc              3   (   K   | ]}|rd | n|V  dS )z  Nr"   )r$   lines     r   r1   z*_dispatchable._make_doc.<locals>.<genexpr>M  sB        6:41KKKKT     r(   
TFextra_parametersadditional_parametersz  Additional parameters:z    z      urlz
[`Source <z>`_]zThe original docstring for z was empty.z
    z

    r   r   z
 such as ""r   z or "z	 such as , c              3   "   K   | ]
}d | d V  dS )r  Nr"   r_  s     r   r1   z*_dispatchable._make_doc.<locals>.<genexpr>  s*      @@QA@@@@@@r(   Nr{   z, or "z
    .. attention:: This function does not have a default NetworkX implementation.
        It may only be run with an installable :doc:`backend </backends>` that
        supports itz.

        Hint: use ``backend=...`` keyword argument to specify a backend or add
        backends to ``nx.config.backend_priority``.)r:   r   rU   rJ   r   r   rS   extendr*   rstripr   joinr#   r   insert)r   linesr0   rW   	func_info	func_docsadd_gapr  paramdescfunc_urlnew_docto_addindexr:   examples                   r   r   z_dispatchable._make_doc2  s    =ZL((>! 
 dmzl:;; )	! )	!G(D$&&CCD,ACCDDDDW%%%$&&$)4;L*L*LR   [)$)4I /00TIMMBS4T4Ty     >Good>S>S       011 :==!899 !  %LL$$$7888#$455 % %ELL000/66t 6_d__555LL$$$$	% R   $==///x !8(888999R    .&B~~ 	KJDIJJJG= 	<IIKKK]]5))F ));;6;;G T]**MM$''EEEl((** 
 El((** #e**$$u););)=)=$
 #e**$$u););)=)=$dm,,H8}}!!X!##5x{555X!##Gx{GG!GGG  ii@@(3B3-@@@@@A.x|.../ F&-F F F  LL'''ii&&Gr(   c                      t           | j        ffS )zAllow this object to be serialized with pickle.

        This uses the global registry `_registered_algorithms` to deserialize.
        )_restore_dispatchabler   )r   s    r   
__reduce__z_dispatchable.__reduce__  s    
 %tyl22r(   r/   )r   r   r   r   r   propertyrO   setterr   r   r   r:   r   typingCallable__annotations__r   r   r   r   r   r(  r  r   r   r   r   r  r"   r(   r   r
   r
      s*        K @ !!" @ @ @ @ @D   X ^    ^  " " X"J @D 
/ 
/ 
/ 
/ 
/ AE i
 i
 i
 i
 i
Z ,4W''9W fo   
 
 
2  + + +  2  0K( K( K(Z{ { {z OS     > N N N N Nb =BT  T  T  T  T l] ] ]~3 3 3 3 3r(   c                 &    t           |          j        S r/   )r   r   )r   s    r   r  r    s    !$'33r(   c                     | !t          |                                           n||!t          |                                          n|fS )zLReturn key used by networkx caching given arguments for ``convert_from_nx``.)	frozensetr   r+  s        r   r-  r-    sX     ! 	*""$$%%% ! 	*""$$%%%  r(   )rj   r   c                J   |*|                      di                                |i           } | sdS |\  }}t          j        |dur|dfnd|dur|dfnd          D ]I}|                      |          x}0|t          k    s||k    r||                    | |f           ||fc S Jt          |                                           D ]\  \  }}	}
|
t          k    rY|du s|du rn|du s|du s|                    |          s:|	du s|du rn|	du s|du s|	                    |          sat          | |<   n'|du s|du rn|du s|du s|                    |          s|du s|	du rn|du s|	du s|                    |	          s||                    | ||	ff           ||	f|
fc S dS )a  Search the networkx cache for a graph that is compatible with ``key``.

    Parameters
    ----------
    cache : dict
        If ``backend_name`` is given, then this is treated as ``G.__networkx_cache__``,
        but if ``backend_name`` is None, then this is treated as the resolved inner
        cache such as ``G.__networkx_cache__["backends"][backend_name]``.
    key : tuple
        Cache key from ``_get_cache_key``.
    backend_name : str, optional
        Name of the backend to control how ``cache`` is interpreted.
    mutations : list, optional
        Used internally to clear objects gotten from cache if inputs will be mutated.

    Returns
    -------
    tuple or None
        The key of the compatible graph found in the cache.
    graph or "FAILED_TO_CONVERT" or None
        A compatible graph if possible. "FAILED_TO_CONVERT" indicates that a previous
        conversion attempt failed for this cache key.
    Nr:   )NNTr  F)rS   r   productr   r   r   r   r  )r   rE   rj   r   edge_keynode_keyr3  r   ekeynkeyr   s              r   r.  r.    si   0 		*b))--lB?? z Hh'$D004g$D004g  " "
 ))J'''B4###sj'8'8$   %!4555r>!!!  $EKKMM22 # #te%%% u}}D 0 0U!2!2$--:Q:Q!2u}}D 0 0U!2!2$--:Q:Q!2*E#JJ$$,,h6G6G6M6Muh6G6G6M6M  edD\2333d|U"""":r(   )rj   c                   |*|                      di                                |i           } i }|\  }}|| |<   |t          k    r|S t          |           D ]y}||k    r	|\  }}	|du s|du rn|du s|du s|                    |          s5|	du s|du rn|	du s|du s|	                    |          s\|                     |d          x}|||<   z|S )a  Set a backend graph to the cache, and remove unnecessary cached items.

    Parameters
    ----------
    cache : dict
        If ``backend_name`` is given, then this is treated as ``G.__networkx_cache__``,
        but if ``backend_name`` is None, then this is treated as the resolved inner
        cache such as ``G.__networkx_cache__["backends"][backend_name]``.
    key : tuple
        Cache key from ``_get_cache_key``.
    graph : graph or "FAILED_TO_CONVERT"
        Setting value to "FAILED_TO_CONVERT" prevents this conversion from being
        attempted in future calls.
    backend_name : str, optional
        Name of the backend to control how ``cache`` is interpreted.

    Returns
    -------
    dict
        The items that were removed from the cache.
    Nr:   FT)r,  r   r   r  r   )
r   rE   r   rj   removedr  r  cur_keyr  r  s
             r   r0  r0    s'   ,   R00;;L"MM
 GHhE#J!!!;; % %c>>
d5==H,,T\\X..dmmH6M6M.5==H,,T\\X..dmmH6M6M.YYw---E:$GGNr(   c                       e Zd ZdZd Zd ZdS )r
  zOSimple wrapper to display arguments of dispatchable functions in logging calls.c                 >    || _         || _        || _        d | _        d S r/   )r   r_   r`   value)r   r   r_   r`   s       r   __init__z_LazyArgsRepr.__init__>  s"    		


r(   c                     | j         b | j        j        j        | j        i | j        }d                    d |j                                        D                       }d| d| _         | j         S )Nr  c              3   *   K   | ]\  }}| d |V  dS )=Nr"   rD   s      r   r1   z)_LazyArgsRepr.__repr__.<locals>.<genexpr>G  s4      WW83..s..WWWWWWr(   (rk  )	r  r   r   bind_partialr_   r`   r  r  r   )r   r  inners      r   __repr__z_LazyArgsRepr.__repr__D  so    :8DI+8$)St{SSEIIWWu?T?T?V?VWWWWWE%UDJzr(   N)r   r   r   rO   r  r  r"   r(   r   r
  r
  ;  s8        YY      r(   r
  _NETWORKX_BUILDING_DOCS_c                 `    | t          t          fi |S t          | fi |}|j        | _        | S r/   )r   r
   _orig_dispatchablerO   )r   r`   dispatched_funcs      r   r
   r
   T  sA    <=33F333,T<<V<<&.r(   c                 $    g | ]\  }}|d k    |S )r   r"   )r$   r   r   s      r   r'   r'   ^  s!    HHH$!QQ%ZZAZZZr(   r   r/   )2r   r   loggingrQ   r  r   	functoolsr   importlib.metadatar   r>   r   configsr   r   r   
decoratorsr	   __all__	getLoggerr   r   r   r   r:   rJ   rg   r   r,   r[   r]   ra   rk   r
   r  r-  r.  r0  r
  rR   rS   r  r   rO   r   r   r   r   r   r   r"   r(   r   <module>r     s  2       				         + + + + + +     > > > > > > > > > >      

'
H
%
%'  +0 + + + + +b =,--    R R RC C CL    
 
 
G3 G3 G3 G3 G3 G3 G3 G3T64 4 4  . 15 Q Q Q Q Qh 6: 0 0 0 0 0f       " :>>,--  '    /6>M7/788D"&,,HH$/"7"7"9"9HHH #/ # #M# r(   