ó
 ,µ[c           @   s½  d  Z  d d l Z y  d d l Z d d l m Z WnQ e k
 r… y  d d l Z d d l m Z Wq† e k
 r e d ƒ ‚ q† Xn Xd d l j	 Z
 d d l Z d d l m Z d d l m Z d „  Z d „  Z e d	 k r¹e ƒ  Z d
 e j e ƒ e j e ƒ f GHe j e ƒ d f GHe
 j d d d ƒe e d d ƒZ e j e ƒ Z xX e D]P Z e j ƒ  g e j e ƒ Z e j e e d d d e d d d d d e  ƒqXWe
 j! ƒ  n  d S(   s=   
=====
Atlas
=====

Atlas of all graphs of 6 nodes or less.

iÿÿÿÿN(   t   graphviz_layouts;   This example needs Graphviz and either PyGraphviz or pydot.(   t   graph_could_be_isomorphic(   t   graph_atlas_gc          C   sò   t  ƒ  d d !}  t j ƒ  } xl |  D]d } g  | D]! } | j | ƒ d k r0 | ^ q0 } x | D] } | j | ƒ q^ Wt j | | ƒ } q# Wt j | ƒ } t j ƒ  } g  } x? | D]7 } t | | ƒ s³ | j | ƒ t j | | ƒ } q³ q³ W| S(   sx    Return the atlas of all connected graphs of 6 nodes or less.
        Attempt to check for isomorphisms and remove.
    i    iĞ   (	   R   t   nxt   Grapht   degreet   remove_nodet   disjoint_uniont   connected_component_subgraphst   isot   append(   t   Atlast   Ut   Gt   nt
   zerodegreet   Ct   UUt   nlist(    (    s5   share/doc/networkx-2.2/examples/drawing/plot_atlas.pyt   atlas6'   s    .c         C   s(   x! | D] } t  |  | ƒ r t Sq Wt S(   sB   Quick and dirty nonisomorphism checker used to check isomorphisms.(   t
   isomorphict   Truet   False(   t   G1t   glistt   G2(    (    s5   share/doc/networkx-2.2/examples/drawing/plot_atlas.pyR	   C   s    t   __main__s    graph has %d nodes with %d edgess   connected componentsi   t   figsizei   t   progt   neatot	   node_sizei(   t
   node_colort   vming        t   vmaxg      ğ?t   with_labels(   i   i   ("   t   __doc__t   randomt
   pygraphvizt   networkx.drawing.nx_agraphR    t   ImportErrort   pydott   networkx.drawing.nx_pydott   matplotlib.pyplott   pyplott   pltt   networkxR   t(   networkx.algorithms.isomorphism.isomorphR   R   t   networkx.generators.atlasR   R   R	   t   __name__R   t   number_of_nodest   number_of_edgest   number_connected_componentst   figuret   posR   R   t   gt   ct   drawR   t   show(    (    (    s5   share/doc/networkx-2.2/examples/drawing/plot_atlas.pyt   <module>	   sD   
				