U
    9%e
                     @   sD  d Z ddlZddlmZ ddiddiddiddiddiddiddiddiddiddiddiddidZdd	d
dddddddddgZe Z	e	
dd e D  e	dd eD  ed 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$d0Z%e$D ]Z&e%ee&d1  7 Z%qe!e% qejefeeed(e e'  e(  dS )2a:  
==================
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colorRedZBlueZ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   |/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/../../../share/doc/networkx-3.1/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  )Zwith_labelsZ
edgecolorsZ	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   )posZ
node_colorwidthr   r%   zS-)prefixz%SNAP Aggregation (%s nodes, %s edges)i typesg        r   ))__doc__ZnetworkxnxZmatplotlib.pyplotZpyplotZpltZnodesedgesZGraphZoriginal_graphZadd_nodes_fromitemsZadd_edges_fromZsuptitleZbase_optionsZsubplotZax1titleZnumber_of_nodesZnumber_of_edgesZspring_layoutr'   Znode_colorsr&   Zedge_weightsZdraw_networkxZnode_attributesZedge_attributesZsnap_aggregationZsummary_graphZsummary_posnoder   appendedgeZget_edge_dataZ
edge_typesZedge_weightZ	edge_typeZtight_layoutshowr   r   r   r   <module>   s   


     