ó
 ,µ[c           @   sÚ  d  Z  d Z d d l m Z d d l j Z d d l Z d d l m	 Z	 d e	 f d „  ƒ  YZ
 e d k rÖe
 ƒ  Z e j d	 ƒ e j d
 d d ƒe j d ƒ e j d ƒ d e j d e ƒ f GHe j d d d d ƒd e j d e ƒ f GHe j d d ƒ e j e e d d ƒ e d d ƒ ƒ d d ƒd e j d e ƒ f GHe j e e d d ƒ e d d ƒ ƒ ƒ d e j d e ƒ f GHe
 ƒ  Z e j e e d ƒ ƒ e j e e d d ƒ ƒ e j e ƒ e j ƒ  n  d S(   sK   
===========
Print Graph
===========

Example subclass of the Graph class.
s   restructuredtext eniÿÿÿÿ(   t   deepcopyN(   t   Grapht
   PrintGraphc           B   sz   e  Z d  Z d d d d „ Z d d „ Z d „  Z d „  Z d „  Z d d „ Z	 d d „ Z
 d	 „  Z d
 „  Z d „  Z RS(   sc   
    Example subclass of the Graph class.

    Prints activity log to file or standard output.
    t    c         K   sY   t  j |  d | d | | | d  k rC d d  l } | j |  _ n t | d ƒ |  _ d  S(   Nt   datat   nameiÿÿÿÿt   w(   R   t   __init__t   Nonet   syst   stdoutt   fht   open(   t   selfR   R   t   filet   attrR	   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR       s
    c         K   s1   t  j |  | d | | |  j j d | ƒ d  S(   Nt	   attr_dicts   Add node: %s
(   R   t   add_nodeR   t   write(   R   t   nR   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR   (   s    c         K   s%   x | D] } |  j  | |  q Wd  S(   N(   R   (   R   t   nodesR   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyt   add_nodes_from,   s    c         C   s(   t  j |  | ƒ |  j j d | ƒ d  S(   Ns   Remove node: %s
(   R   t   remove_nodeR   R   (   R   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR   0   s    c         C   s"   x | D] } |  j  | ƒ q Wd  S(   N(   R   (   R   R   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyt   remove_nodes_from4   s    c         K   s:   t  j |  | | d | | |  j j d | | f ƒ d  S(   NR   s   Add edge: %s-%s
(   R   t   add_edgeR   R   (   R   t   ut   vR   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR   8   s    c         K   sA   x: | D]2 } | d d !\ } } |  j  | | d | | q Wd  S(   Ni    i   R   (   R   (   R   t   ebunchR   R   t   eR   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyt   add_edges_from<   s    c         C   s1   t  j |  | | ƒ |  j j d | | f ƒ d  S(   Ns   Remove edge: %s-%s
(   R   t   remove_edgeR   R   (   R   R   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR   A   s    c         C   s8   x1 | D]) } | d d !\ } } |  j  | | ƒ q Wd  S(   Ni    i   (   R   (   R   R   R   R   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyt   remove_edges_fromE   s    c         C   s!   t  j |  ƒ |  j j d ƒ d  S(   Ns   Clear graph
(   R   t   clearR   R   (   R   (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR    J   s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   R   R   R    (    (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyR      s   					t   __main__t   foot   bart   weighti   t   bt   ars   Nodes in G: R   i    i   i
   s   Edges in G: i   i   i	   i   (   R#   t   __docformat__t   copyR    t   matplotlib.pyplott   pyplott   pltt   networkxt   nxR   R   R!   t   GR   R   R   R   R   t   TrueR   t   edgesR   R   t   zipt   rangeR   t   add_patht   add_start   drawt   show(    (    (    s;   share/doc/networkx-2.2/examples/subclass/plot_printgraph.pyt   <module>   s2   
6	.(	