o
    ˷e                     @   sD  d Z ddlZddlmZ eddeddeddeddeddeddeddeddeddeddeddedddZg dZe	 Z
e
d	d
 e D  e
dd
 eD  ed eddddZedddZede
 e
 f  eje
ddZdd e
jddD ZdddZdd e
jddD Zeje
feeede dZdZeje
eedd Zeddd ed!e e f  ejed"dZg ZeD ]Z eje  d# Z!e"e! qg Ze D ]Z#ej$e# d$ Z%d%Z&e%D ]
Z'e&ee'd&  7 Z&qe"e& qejefeeede e(  e)  dS )'a:  
==================
SNAP Graph Summary
==================
An example of summarizing a graph based on node attributes and edge attributes
using the Summarization by Grouping Nodes on Attributes and Pairwise
edges (SNAP) algorithm (not to be confused with the Stanford Network
Analysis Project).  The algorithm groups nodes by their unique
combinations of node attribute values and edge types with other groups
of nodes to produce a summary graph.  The summary graph can then be used to
infer how nodes with different attributes values relate to other nodes in the
graph.
    NRedcolorBlueYellow)ABCDEFGHIJKL))r   r   Strong)r   r	   Weak)r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r	   r   r   )r
   r   r   )r   r   r   )r   r   r   )r   r   r   c                 c   s    | ]}|V  qd S )N ).0nr   r   v/var/www/ideatree/venv/lib/python3.10/site-packages/../../../share/doc/networkx-2.8.6/examples/algorithms/plot_snap.py	<genexpr>/   s    r   c                 c   s$    | ]\}}}||d |ifV  qdS )typeNr   )r   uvlabelr   r   r   r   0   s   " zSNAP SummarizationTblacki  )with_labels
edgecolors	node_size      zOriginal (%s nodes, %s edges)i6.r )seedc                 C   s   g | ]\}}|d  qS r   r   r   _dr   r   r   
<listcomp>=   s    r(   )datag      ?g      @)r   r   c                 C   s   g | ]\}}}t |d   qS r   )edge_type_visual_weight_lookupr%   r   r   r   r(   @   s    
)pos
node_colorwidthr*   zS-)prefixz%SNAP Aggregation (%s nodes, %s edges)i r   typesg        r   )*__doc__networkxnxmatplotlib.pyplotpyplotpltdictnodesedgesGraphoriginal_graphadd_nodes_fromitemsadd_edges_fromsuptitlebase_optionssubplotax1titlenumber_of_nodesnumber_of_edgesspring_layoutr,   node_colorsr+   edge_weightsdraw_networkxnode_attributesedge_attributessnap_aggregationsummary_graphsummary_posnoder   appendedgeget_edge_data
edge_typesedge_weight	edge_typetight_layoutshowr   r   r   r   <module>   s    


