o
    3ήc                     @   s   d dl Z d dlZd dlmZ dd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  ZdS )!    N)NetworkXNotImplementedc                 C   ,   dd | D }dd |D }||ksJ d S )Nc                 S      h | ]}t d d |D qS )c                 s       | ]}t |V  qd S N	frozenset.0e r   \/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/components/tests/test_biconnected.py	<genexpr>       :assert_components_edges_equal.<locals>.<setcomp>.<genexpr>r   r
   cr   r   r   	<setcomp>       z0assert_components_edges_equal.<locals>.<setcomp>c                 S   r   )c                 s   r   r   r   r	   r   r   r   r   	   r   r   r   r   r   r   r   r   	   r   r   xysxsyr   r   r   assert_components_edges_equal      r   c                 C   r   )Nc                 S      h | ]}t |qS r   r   r   r   r   r   r          z*assert_components_equal.<locals>.<setcomp>c                 S   r   r   r   r   r   r   r   r      r   r   r   r   r   r   assert_components_equal   r   r   c                  C   s   t dd} t | g d t | g d tt | }|h dks%J h dh dh dd	d
hdd	hddhddhddhddhddhddhg}ttt | | | 	dd tt | }|h dksgJ d S )N      )            )r$            >	   r!   r   	   
         r"   r#   r$   >   r+                        >   r            r          r!   >   r$   r%   r&   r'   r*   r+   r)   r(   r!   r#   r$   r"   r4   r0   >   r!   r"   r#   r$   )
nxbarbell_graphadd_path	add_cyclesetarticulation_pointsr   listbiconnected_componentsadd_edge)Gptsanswerr   r   r   test_barbell   s*   rD   c                  C   s2   t  } | g d tt | dgksJ d S )N)r   r3   )r3   r4   )r3   r5   r3   )r8   Graphadd_edges_fromr>   r=   rA   r   r   r   $test_articulation_points_repetitions.   s   rI   c                  C   s:   t d} t | g d tt | }|dhksJ d S )Nr5   r3   r5   r    r3   )r8   cycle_graphr;   r<   r=   )rA   rB   r   r   r   test_articulation_points_cycle4   s   
rL   c                  C   s:   t d} t | sJ t | g d t | rJ d S )Nr5   rJ   )r8   rK   is_biconnectedr;   rH   r   r   r   test_is_biconnected;   s   
rN   c                  C   s6   t d} t | rJ | dd t | rJ d S )Nr6   r   r3   )r8   empty_graphrM   r@   rH   r   r   r   test_empty_is_biconnectedB   s   
rP   c                  C   sB   t d} t | g d h dh dg}ttt | | d S )Nr5   rJ   >   r   r3   r4   >   r3   r5   r    )r8   rK   r;   r   r>   r?   )rA   rC   r   r   r   !test_biconnected_components_cycleI   s   
rQ   c                  C   sr   g d} t | }tt |}|h dksJ tt |}g dg ddgdgdgdgg d	g}t|| d S )
N)rE   )r   r6   )r   r7   )r   r-   )r3   r6   r3   r7   )r3   r-   )r4   r    r4   r)   r5   r    )r5   r.   )r    r7   r    r!   )r    r)   )r6   r-   r7   r-   r!   r(   )r   r(   r   r+   )r   r,   r)   r.   )r*   r+   r*   r,   )r+   r,   >   r    r7   r!   r   r(   )rT   )r.   r5   rY   )r)   r    rS   )r    r4   ))r,   r+   )r,   r   rZ   )r+   r*   rX   )r(   r   rW   rU   )r7   r    )	)r-   r   )r6   r3   )r6   r   )r-   r6   )r-   r3   rV   )r7   r   rR   rE   )r8   rF   r<   r=   r>   biconnected_component_edgesr   )edgesrA   rB   compsrC   r   r   r   test_biconnected_components1P   s   
	r^   c                  C   s   t  } t | d t | d t | d t | d | dd tt | }tdtdtd	td
tdtdtdgtdgtdtdtdgtdtdtdgg}t|| d S )NABCCDEFIJHGGIJErA   GFFIIGIJJGJHHGEGCDDECEABBCAC)r8   rF   r;   r@   r>   r[   tupler   )rA   r]   rC   r   r   r   test_biconnected_components2}   s(   	rs   c                  C   sH   t  } tt | d }t| |ksJ ttt | dks"J d S )Nr   )r8   davis_southern_women_graphr>   r?   r<   lenr=   )Dbccr   r   r   test_biconnected_davis   s   rx   c                  C   sR   t  } h dh dddhg}tt | }t|| tt | dhks'J d S )N>   r   r3   r4   r5   r!   r   r(   r+   r,   r-   r.   r0   r1   r2   r"   r#   r$   r%   r&   r'                         !   >   r   r    r6   r7   r)   r/   r   r*   )r8   karate_club_graphr>   r?   r   r<   r=   )KrC   rw   r   r   r   test_biconnected_karate   s   "
r   c                  C   s   t g dddgg dg dg dg ddd	gd
} t ddgddgg dg ddgddgddgd	gg dd	}t | sAJ t |rHJ h dh dddhd	dhg}tt |}t|| d S )N)r3   r4   r6   r   r6   )r   r5   r    )r4   r    r6   r7   )r4   r5   r6   r7   )r   r3   r5   r    r5   r    )r   r3   r4   r5   r    r6   r7   r4   r   )r   r5   r6   )r3   r4   r7   r   r!   )r3   r5   r7   )	r   r3   r4   r5   r    r6   r7   r!   r   >   r3   r5   r7   r   >   r   r4   r6   )r8   rF   rM   r>   r?   r   )G1G2	answer_G2rw   r   r   r   test_biconnected_eppstein   s6   r   c                  C   s\   t  } t | rJ tt | g ksJ tt | g ks!J tt | g ks,J d S r   )r8   rF   rM   r>   r?   r[   r=   rH   r   r   r   test_null_graph   s
   r   c                  C   s   t  } tt tt |  W d    n1 sw   Y  tt tt |  W d    n1 s7w   Y  tt tt |  W d    n1 sSw   Y  ttt j	|  d S r   )
r8   DiGraphpytestraisesr   nextr?   r[   r=   rM   )DGr   r   r   test_connected_raise   s   r   )r   networkxr8   r   r   r   rD   rI   rL   rN   rP   rQ   r^   rs   rx   r   r   r   r   r   r   r   r   <module>   s$    -)!