
    Gd              
          d Z ddlmZ ddlZ ej        d            ej                    Zg dZ	g dZ
d e	e
z   D             Zd e	D             d e
D             z   Ze                    e	e
z              e                    g d	           d
ddZdddddddddd	Z ej        ddd          Z ej        de                                z              ej        efeede ej                            edd          \  ZZ ee          Z ee          ZeD ],Ze                    d           e                    d           - ej        ddd            ej        de                                z             d ddd!d"d#dd$d%d&	Z ee          Z e !                                  e"e           D ]\  Z#Zde#dz   fee<    ej        efeeed'e  ej$                      ej%                     dS )(a  
===============
Dedensification
===============

Examples of dedensification of a graph.  Dedensification retains the structural
pattern of the original graph and will only add compressor nodes when doing so
would result in fewer edges in the compressed graph.
    NDedensification)123456)ABCc                     g | ]}d S )    ).0nodes     Bshare/doc/networkx-3.1/examples/algorithms/plot_dedensification.py
<listcomp>r      s    666dc666    c                     g | ]}d S )whiter   r   ns     r   r   r      s    ,,,1w,,,r   c                     g | ]}d S )redr   r   s     r   r   r      s    /I/I/I!/I/I/Ir   ))r   r   )r   r   )r   r   )r   r   )r   r
   )r   r   )r   r
   )r   r	   )r   r   )r   r   )r   r
   )r   r   )r   r
   )r	   r   )r
   r	   Tblack)with_labels
edgecolors)r      )r      )r      )r   r   )r   r   )r   r   )r   r    )r   r    )r   r   )	r   r   r   r	   r
   r   r   r   r   r   r   zOriginal (%s edges))pos
node_colorF)	thresholdcopyyellowiX  zDedensified (%s edges))r   r   )r   g      ?)      ?r&   )r   r   )r    r&   )r    g      @)	r   r   r   r	   r   r
   r   r   r   )r!   r"   	node_size)&__doc__matplotlib.pyplotpyplotpltnetworkxnxsuptitleDiGraphoriginal_graphwhite_nodes	red_nodes
node_sizesnode_colorsadd_nodes_fromadd_edges_frombase_optionsr!   subplotax1titlenumber_of_edgesdraw_networkxsummarization	dedensifynonexp_graphcompression_nodeslistnonexp_node_colorsnonexp_node_sizesr   append
nonexp_posc_nodessort	enumeratespottight_layoutshowr   r   r   <module>rL      s                  ,,,OO	66kI5666
,,,,,/I/Iy/I/I/II   kI5 6 6 6       &  $7;;									
 
 ck!Q 		
."@"@"B"B
B C C C   QS[ Q QL Q Q Q"$"2"<"<ae #= # #  T+&& D$$  " "Dh'''S!!!! Aq!    		
"\%A%A%C%C
C D D D									
 

 $ 
!
! )G$$ % %JD$4!8}Jt  !	 
         




r   