o
    ˷e                     @   sT  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jeddZeee e  dS )zK
===========
Print Graph
===========

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

    Prints activity log to file or standard output.
    N c                    sD   t  jd||d| |d u r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__r   z/var/www/ideatree/venv/lib/python3.10/site-packages/../../../share/doc/networkx-2.8.6/examples/subclass/plot_printgraph.pyr
      s
   zPrintGraph.__init__c                    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    |D ]}| j |fi | qd S N)r   )r   nodesr   r   r   r   r   add_nodes_from"   s   zPrintGraph.add_nodes_fromc                    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   |D ]}|  | qd S r   )r   )r   r   r   r   r   r   remove_nodes_from*   s   zPrintGraph.remove_nodes_fromc                    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   s6   |D ]}|dd \}}| j ||fd|i| qd S )Nr      r   )r    )r   ebunchr   r   er!   r"   r   r   r   add_edges_from2   s   zPrintGraph.add_edges_fromc                    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*   |D ]}|dd \}}|  || qd S )Nr   r#   )r'   )r   r$   r%   r!   r"   r   r   r   remove_edges_from;   s   zPrintGraph.remove_edges_fromc                    s   t    | jd d S )NzClear graph
)r	   clearr   r   )r   r   r   r   r)   @   s   
zPrintGraph.clear)Nr   Nr   )__name__
__module____qualname____doc__r
   r   r   r   r   r    r&   r'   r(   r)   __classcell__r   r   r   r   r      s    	
r   foobar   )weightbarzNodes in G: T)r      
   zEdges in G:       	         )seed)r-   matplotlib.pyplotpyplotpltnetworkxnxr   r   Gr   r   r   r   printr   r    edgesr'   r&   zipranger(   add_pathadd_starspring_layoutposdrawshowr   r   r   r   <module>   s0    7


 