o
    ]ZhO                     @   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__Z__networkx_backend__ r   r   X/var/www/auris/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backendsZ_registered_algorithmsZ	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>   Z lexicographical_topological_sortZtopological_sortZtopological_generationsz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Z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   )r-   r.   r6   r   r   r3      s    zSLoopbackBackendInterface.convert_from_nx.<locals>.G_new_datadict.<locals>.<genexpr>)r5   itemsr6   )r8   r%   r6   r   r9      s   c                    s      S r   r4   r6   r7   r   r   r9      s   c                    s      fdd|  D }|S )Nc                 3        | ]\}}| |fV  qd S r   r   )r/   kdd)r9   r   r   r3      s    
zPLoopbackBackendInterface.convert_from_nx.<locals>.G_new_inner.<locals>.<genexpr>)Zadjlist_inner_dict_factoryr:   )Zkeydictkd)r8   r9   r   r   G_new_inner   s   z=LoopbackBackendInterface.convert_from_nx.<locals>.G_new_innerc                 3   r;   r   r   r/   nbrr=   )r?   r   r   r3          c                 3   s     | ]}| |  fV  qd S r   r   )r/   rA   )G_adjr2   r   r   r3      rB   c                 3   s8    | ]\}}| | v r |  n|fV  qd S r   r   r@   )rC   r?   r2   r   r   r3      s
    "
)r   r   r   Zadd_nodes_fromr:   r	   r   r   	__class__r   r   r   r   r   r   r   r   r   updater,   nodesZis_multigraphZ_adjZis_directedZ_pred)r   r%   r&   r'   r(   r)   r*   r+   Z	new_graphr=   ZnbrsZG_predr   )r8   rC   r9   r?   r%   r   r2   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 )NZ
add_markerhasattr)r:   r#   r   r   r   on_start_tests   s   z'LoopbackBackendInterface.on_start_testsc                 C   s
   t | |S r   rJ   )r"   r*   argskwargsr   r   r   can_run   s   
z LoopbackBackendInterface.can_run)	r   r   r   r$   staticmethodrG   rI   rL   rO   r   r   r   r   r   4   s     m
r   )Znetworkxr   r   r   r   r   r   Znetworkx.classes.reportviewsr   r	   r   r   r   r   r   r   Zbackend_interfacer   r   r   r   <module>   s    
