
    GdN                     "   d Z ddlZddlZddlZddlmZ ddlZd Z	 e	            Z
 ed            ee
           e
                                Z e ej        e          d           ddddd	d
Z ej        efi e  ej                     dS )a  
=====
Roget
=====

Build a directed graph of 1022 categories and 5075 cross-references as defined
in the 1879 version of Roget's Thesaurus. This example is described in Section
1.2 of

    Donald E. Knuth, "The Stanford GraphBase: A Platform for Combinatorial
    Computing", ACM Press, New York, 1993.
    http://www-cs-faculty.stanford.edu/~knuth/sgb.html

Note that one of the 5075 cross references is a self loop yet it is included in
the graph built here because the standard networkx `DiGraph` class allows self
loops.  (cf. 400pungency:400 401 403 405).

The data file can be found at:

- https://github.com/networkx/networkx/blob/main/examples/graph/roget_dat.txt.gz
    Nc                     t          j        dd          } t          j                    }|                                 D ]}|                                }|                    d          r-|                    d          r||z   }|                    d          r|                    d          }r|	                    d          \  }}t          j        d          }|                    |          d         }|                    |           |	                                D ];}||k    rt          d	||t          j        
           |                    ||           < |S )zZReturn the thesaurus graph from the roget.dat example in
    the Stanford Graph Base.
    zroget_dat.txt.gzr* z\
:z^\d+r   zskipping self loop)file)gzipopennxDiGraph	readlinesdecode
startswithendswithstripsplitrecompilefindalladd_nodeprintsysstderradd_edge)	fhGlineoldlineheadnametailsnumfindheadtails	            3share/doc/networkx-3.1/examples/graph/plot_roget.pyroget_graphr%      sK   
 
%s	+	+B

A # #{{}}??3 	??3 	"T>D==   	jj((G JJsOO5 *W%%x((+	

4KKMM 	# 	#Dt||*D$SZHHHHJJtT""""	#
 H    z0Loaded roget_dat.txt containing 1022 categories.zconnected componentsblack   grayg?)
node_color	node_size
edge_color
linewidthswidth)__doc__r	   r   r   matplotlib.pyplotpyplotpltnetworkxr   r%   r   r   to_undirectedUGnumber_connected_componentsoptionsdraw_circularshow r&   r$   <module>r;      s    ,  				 



               F KMM 8 9 9 9 a__ $b$R((*@ A A A      w    




r&   