a
    h                     @   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                   @   s   e Zd ZdZdS )LoopbackGraphnx-loopbackN__name__
__module____qualname__Z__networkx_backend__ r   r   W/var/www/auris/lib/python3.9/site-packages/networkx/classes/tests/dispatch_interface.pyr      s   r   c                   @   s   e Zd ZdZdS )LoopbackDiGraphr	   Nr
   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdS )LoopbackMultiGraphr	   Nr
   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdS )LoopbackMultiDiGraphr	   Nr
   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdS )LoopbackPlanarEmbeddingr	   Nr
   r   r   r   r   r   "   s   r   c                 C   sp   t | trt| S t | tr$t| S t | tr6t| S t | trHt| S t | t	rZt
| S tdt|  d S )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 )LoopbackDispatcherc                 C   s4   zt jjj| jW S  ty.   t|d Y n0 d S N)nxutilsbackendsZ_registered_algorithmsZ	orig_funcKeyErrorAttributeError)selfitemr   r   r   __getattr__5   s    zLoopbackDispatcher.__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r6t }||   |} t }	nt | ts`td| d| dt|  nv| jtthv rvt }	n`| jt	t
hv rt
 }	nJ| jtthv rt }	n4| jtthv rt }	n| jtthv rt
 }	n|  }	|r|	j| j |r|	| jdd n2r*|	fdd| jddD  n
|	|  |  r|r`|	d	d | j D  n@ r|	 fd
d| j D  n|	dd | j D  nN|r|	| jdd n4 r|	 fdd| jddD  n|	| j |	S )N>   Ztopological_generationsZ lexicographical_topological_sortZtopological_sortZdfs_labeled_edgeszBad type for graph argument z in z: T)datac                 3   s,   | ]$\} | fd d  D fV  qdS )c                    s.   i | ]&\}}|d us| v r|  ||qS r   get.0kdefaultdatadictr   r   
<dictcomp>u   s   @LoopbackDispatcher.convert_from_nx.<locals>.<genexpr>.<dictcomp>Nitems)r.   node)r$   r1   r   	<genexpr>r   s   	
z5LoopbackDispatcher.convert_from_nx.<locals>.<genexpr>c                 s   sB   | ]:\}}|  D ](\}}|  D ]\}}||||fV  q"qqd S r   r5   r.   unbrsvkeydictkeyr2   r   r   r   r8      s   c              	   3   sT   | ]L\}}|  D ]:\}}|  D ](\} ||| fd d  D fV  q"qqdS )c                    s.   i | ]&\}}|d us| v r|  ||qS r   r+   r-   r1   r   r   r3      s   r4   Nr5   )r.   r:   r;   r<   r=   r>   r#   r1   r   r8      s   
c                 s   sB   | ]:\}}|  D ](\}}|  D ]\}}|||i fV  q"qqd S r   r5   r9   r   r   r   r8      s   c                 3   s0   | ](\}} || fd d  D fV  qdS )c                    s.   i | ]&\}}|d us| v r|  ||qS r   r+   r-   r1   r   r   r3      s   r4   Nr5   )r.   r:   r<   r?   r1   r   r8      s   

)r   r   r   Zadd_nodes_fromr6   r   r   r   	__class__r   r   r   r   r   r   r   r   r   updatenodesZis_multigraphZadd_edges_fromZ_adjedges)
r   r#   r$   r%   r&   r'   r(   r)   Z	new_graphGr   )r#   r$   r   convert_from_nx;   sf    

	











z"LoopbackDispatcher.convert_from_nx)r(   c                C   s   | S r   r   )objr(   r   r   r   convert_to_nx   s    z LoopbackDispatcher.convert_to_nxc                 C   s   | D ]}t |dsJ qd S )NZ
add_markerhasattr)r6   r!   r   r   r   on_start_tests   s    z!LoopbackDispatcher.on_start_testsc                 C   s
   t | |S r   rH   )r    r(   argskwargsr   r   r   can_run   s    zLoopbackDispatcher.can_run)	r   r   r   r"   staticmethodrE   rG   rJ   rM   r   r   r   r   r   4   s   v
r   )Znetworkxr   r   r   r   r   r   Znetworkx.classes.reportviewsr   r   r   r   r   r   r   r   
dispatcherr   r   r   r   <module>   s    