
    Gd              	          d Z ddlmZ ddlZddlmZ  G d de          Z e            Ze	                    d           e
                    dd	           e                    d
           e                    d            ede                    d                     e                    ddd	            ede                    d                     e                    dd           e                     e edd           edd                    d	            ede                    d                     e                     e edd           edd                                ede                    d                      e            Z ej        e ed                      ej        e edd                      ej        ed          Z ej        ee            ej                     dS )zK
===========
Print Graph
===========

Example subclass of the Graph class.
    N)Graphc                   t     e Zd ZdZd fd	Zd fd	Zd Z fdZd Zd fd		Z	dd
Z
 fdZd Z fdZ xZS )
PrintGraphzc
    Example subclass of the Graph class.

    Prints activity log to file or standard output.
    N c                      t                      j        d||d| |dd l}|j        | _        d S t          |d          | _        d S )N)datanamer   w )super__init__sysstdoutfhopen)selfr   r	   fileattrr   	__class__s         ;share/doc/networkx-3.1/examples/subclass/plot_printgraph.pyr   zPrintGraph.__init__   sU    6d66666<JJJjDGGG4ooDGGG    c                 |     t                      j        |fd|i| | j                            d| d           d S )N	attr_dictz
Add node: 
)r   add_noder   write)r   nr   r   r   s       r   r   zPrintGraph.add_node   sM    88i84888(1((()))))r   c                 ,    |D ]} | j         |fi | d S N)r   )r   nodesr   r   s       r   add_nodes_fromzPrintGraph.add_nodes_from"   s8     	% 	%ADM!$$t$$$$	% 	%r   c                     t                                          |           | j                            d| d           d S )NzRemove node: r   )r   remove_noder   r   )r   r   r   s     r   r#   zPrintGraph.remove_node&   sA    A+a+++,,,,,r   c                 :    |D ]}|                      |           d S r   )r#   )r   r    r   s      r   remove_nodes_fromzPrintGraph.remove_nodes_from*   s2     	  	 AQ	  	 r   c                      t                      j        ||fd|i| | j                            d| d| d           d S )Nr   z
Add edge: -r   )r   add_edger   r   )r   uvr   r   r   s        r   r(   zPrintGraph.add_edge.   sW    A;;;d;;;,1,,q,,,-----r   c                 L    |D ] }|dd         \  }} | j         ||fd|i| !d S )Nr      r   )r(   )r   ebunchr   r   er)   r*   s          r   add_edges_fromzPrintGraph.add_edges_from2   sP     	= 	=AQqS6DAqDM!Q<<)<t<<<<	= 	=r   c                     t                                          ||           | j                            d| d| d           d S )NzRemove edge: r'   r   )r   remove_edger   r   )r   r)   r*   r   s      r   r1   zPrintGraph.remove_edge7   sK    Aq!!!/a//!///00000r   c                 V    |D ]%}|dd         \  }}|                      ||           &d S )Nr   r,   )r1   )r   r-   r.   r)   r*   s        r   remove_edges_fromzPrintGraph.remove_edges_from;   sE     	# 	#AQqS6DAqQ""""	# 	#r   c                 |    t                                                       | j                            d           d S )NzClear graph
)r   clearr   r   )r   r   s    r   r5   zPrintGraph.clear@   s.    o&&&&&r   )Nr   Nr   )__name__
__module____qualname____doc__r   r   r!   r#   r%   r(   r/   r1   r3   r5   __classcell__)r   s   @r   r   r      s        & & & & & &* * * * * *% % %- - - - -     . . . . . .= = = =
1 1 1 1 1# # #
' ' ' ' ' ' ' ' 'r   r   foobar   )weightbarzNodes in G: T)r      
   zEdges in G:       	         )seed)r9   matplotlib.pyplotpyplotpltnetworkxnxr   r   Gr   r!   r#   r%   printr    r(   edgesr1   r/   zipranger3   add_pathadd_starspring_layoutposdrawshowr   r   r   <module>rY      sa                    4' 4' 4' 4' 4' 4' 4' 4'n JLL 

5      q  ! ! ! c      D    nagg4g(( ) ) ) 

1a
    nagg4g(( ) ) ) a      UU1a[[%%1++..r  : : : nagg4g(( ) ) )   CCaUU1a[[11 2 2 2 nagg4g(( ) ) )JLL AuuRyy    AuuQ||   bqs### 3 




r   