o
    hO                     @   s   d dl Zd dl mZmZmZmZmZ d dlmZ G dd deZ	G dd deZ
G dd	 d	eZG d
d deZG dd deZdd ZG dd dZe ZdS )    N)DiGraphGraphMultiDiGraph
MultiGraphPlanarEmbedding)NodeViewc                   @      e Zd ZdZdS )LoopbackGraphnx_loopbackN__name__
__module____qualname____networkx_backend__ r   r   ]/var/www/vscode/kcb/lib/python3.10/site-packages/networkx/classes/tests/dispatch_interface.pyr	          r	   c                   @   r   )LoopbackDiGraphr
   Nr   r   r   r   r   r      r   r   c                   @   r   )LoopbackMultiGraphr
   Nr   r   r   r   r   r      r   r   c                   @   r   )LoopbackMultiDiGraphr
   Nr   r   r   r   r   r      r   r   c                   @   r   )LoopbackPlanarEmbeddingr
   Nr   r   r   r   r   r   "   r   r   c                 C   sl   t | tr	t| S t | trt| S t | trt| S t | tr$t| S t | t	r-t
| S tdt|  )NzUnsupported type of graph: )
isinstancer   r   r   r   r   r   r   r   r   r	   	TypeErrortype)graphr   r   r   convert&   s   




r   c                	   @   sX   e Zd Zdd ZeddddddddddZedddd	Zed
d Zdd ZdS )LoopbackBackendInterfacec                 C   s,   z	t jjj| jW S  ty   t|d w N)nxutilsbackends_registered_algorithms	orig_funcKeyErrorAttributeError)selfitemr   r   r   __getattr__5   s
   
z$LoopbackBackendInterface.__getattr__N)
edge_attrs
node_attrspreserve_edge_attrspreserve_node_attrspreserve_graph_attrsname
graph_namec                   s\  |dv rS t trt }|  |t  nOt ts/td| d| dt jtthv r:t  n0jt	t
hv rEt
  n%jtthv rPt  njtthv r[t  njtthv rft
  n  |rs jj   |r j D ]\}	|	j  qn|r j D ]\}	|	fdd| D  q|r fddnr fd	dn fd
d  r͇ fddn j  rj D ]\}
 fdd|
 D  q܈ j}j D ]\}
| fdd|
D  q S j D ]\}
 fdd|
 D  q S )N>   topological_sorttopological_generations lexicographical_topological_sortzBad type for graph argument z in z: c                 3   s@    | ]\}}|d us| j  v r| j  ||fV  qd S r   )_nodeget.0attrdefault)r   nr   r   	<genexpr>t   s    z;LoopbackBackendInterface.convert_from_nx.<locals>.<genexpr>c                    s
     | S r   edge_attr_dict_factoryold_ddGr   r   G_new_datadict}   s   
z@LoopbackBackendInterface.convert_from_nx.<locals>.G_new_datadictc                    s     fdd D S )Nc                 3   s4    | ]\}}|d us| v r|  ||fV  qd S r   )r3   r4   r<   r   r   r9      s    zSLoopbackBackendInterface.convert_from_nx.<locals>.G_new_datadict.<locals>.<genexpr>)r;   itemsr<   )r?   r(   r<   r   r@      s   c                    s      S r   r:   r<   r>   r   r   r@      s   c                    s      fdd|  D }|S )Nc                 3        | ]\}}| |fV  qd S r   r   )r5   kdd)r@   r   r   r9      s    
zPLoopbackBackendInterface.convert_from_nx.<locals>.G_new_inner.<locals>.<genexpr>)adjlist_inner_dict_factoryrA   )keydictkd)r?   r@   r   r   G_new_inner   s   z=LoopbackBackendInterface.convert_from_nx.<locals>.G_new_innerc                 3   rB   r   r   r5   nbrrD   )rH   r   r   r9          c                 3   s     | ]}| |  fV  qd S r   r   )r5   rJ   )G_adjr8   r   r   r9      rK   c                 3   s8    | ]\}}| | v r |  n|fV  qd S r   r   rI   )rL   rH   r8   r   r   r9      s
    "
)r   r   r   add_nodes_fromrA   r	   r   r   	__class__r   r   r   r   r   r   r   r   r   updater2   nodesis_multigraph_adjis_directed_pred)r   r(   r)   r*   r+   r,   r-   r.   	new_graphrD   nbrsG_predr   )r?   rL   r@   rH   r(   r   r8   r   convert_from_nx;   sn   




" 	z(LoopbackBackendInterface.convert_from_nx)r-   c                C   s   | S r   r   )objr-   r   r   r   convert_to_nx   s   z&LoopbackBackendInterface.convert_to_nxc                 C   s   | D ]	}t |dsJ qd S )N
add_markerhasattr)rA   r&   r   r   r   on_start_tests   s   z'LoopbackBackendInterface.on_start_testsc                 C   s
   t | |S r   r\   )r%   r-   argskwargsr   r   r   can_run   s   
z LoopbackBackendInterface.can_run)	r   r   r   r'   staticmethodrX   rZ   r^   ra   r   r   r   r   r   4   s     m
r   )networkxr   r   r   r   r   r   networkx.classes.reportviewsr   r	   r   r   r   r   r   r   backend_interfacer   r   r   r   <module>   s    
