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

Example subclass of the Graph class.
    N)Graphc               @   sh   e Zd ZdZdddZdddZdd	 Zd
d Zdd ZdddZ	dddZ
dd Zdd Zdd ZdS )
PrintGraphzc
    Example subclass of the Graph class.

    Prints activity log to file or standard output.
    N c             K   sB   t j| f||d| |d kr2dd l}|j| _nt|d| _d S )N)datanamer   w)r   __init__sysstdoutfhopen)selfr   r   fileattrr	    r   p/home/dcms/DCMS/lib/python3.7/site-packages/../../../share/doc/networkx-2.5/examples/subclass/plot_printgraph.pyr      s
    
zPrintGraph.__init__c             K   s0   t j| |fd|i| | jd| d d S )N	attr_dictz
Add node: 
)r   add_noder   write)r   nr   r   r   r   r   r      s    zPrintGraph.add_nodec             K   s    x|D ]}| j |f| qW d S )N)r   )r   nodesr   r   r   r   r   add_nodes_from"   s    
zPrintGraph.add_nodes_fromc             C   s$   t | | | jd| d d S )NzRemove node: r   )r   remove_noder   r   )r   r   r   r   r   r   &   s    zPrintGraph.remove_nodec             C   s   x|D ]}|  | qW d S )N)r   )r   r   r   r   r   r   remove_nodes_from*   s    
zPrintGraph.remove_nodes_fromc             K   s8   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   r   r   r   .   s    zPrintGraph.add_edgec             K   s:   x4|D ],}|dd \}}| j ||fd|i| qW d S )Nr      r   )r   )r   ebunchr   r   er   r   r   r   r   add_edges_from2   s    
zPrintGraph.add_edges_fromc             C   s,   t | || | jd| d| d d S )NzRemove edge: r   r   )r   remove_edger   r   )r   r   r   r   r   r   r#   7   s    zPrintGraph.remove_edgec             C   s.   x(|D ] }|dd \}}|  || qW d S )Nr   r   )r#   )r   r    r!   r   r   r   r   r   remove_edges_from;   s    
zPrintGraph.remove_edges_fromc             C   s   t |  | jd d S )NzClear graph
)r   clearr   r   )r   r   r   r   r%   @   s    
zPrintGraph.clear)Nr   N)N)N)N)__name__
__module____qualname____doc__r   r   r   r   r   r   r"   r#   r$   r%   r   r   r   r   r      s   
	


r   Zfoobar   )ZweightbarzNodes in G: T)r      
   zEdges in G:       	      )r)   Zmatplotlib.pyplotZpyplotZpltZnetworkxZnxr   r   Gr   r   r   r   printr   r   edgesr#   r"   zipranger$   Zadd_pathZadd_starZdrawshowr   r   r   r   <module>   s,   7


 
