Ë
    åhi–  ã                   óB   — d Z ddlZddlmZ ddlmZmZ dd„Zdd„Zd„ Z	y)	zg
altgraph.GraphUtil - Utility classes and functions
==================================================
é    N)Údeque)ÚGraphÚ
GraphErrorc                 ó–  — t        j                   «       }|s |r| | z  }n| | dz
  z  }||kD  rt        d«      ‚t        | «      }|D ]  }|j                  |«       Œ 	 t	        j
                  |«      }t	        j
                  |«      }	||	k(  r|sŒ3|j                  ||	«      �|sŒH|j                  ||	«       |j                  «       |k\  r	 |S Œp)zŽ
    Generates and returns a :py:class:`~altgraph.Graph.Graph` instance with
    *node_num* nodes randomly connected by *edge_num* edges.
    é   z1inconsistent arguments to 'generate_random_graph')	r   r   ÚrangeÚadd_nodeÚrandomÚchoiceÚedge_by_nodeÚadd_edgeÚnumber_of_edges)
Únode_numÚedge_numÚ
self_loopsÚmulti_edgesÚgÚ	max_edgesÚnodesÚnodeÚheadÚtails
             ú>C:\des-py\Monitor\venv\Lib\site-packages\altgraph/GraphUtil.pyÚgenerate_random_graphr      sÚ   € ô
 	�‰‹€AáÙØ  8Ñ+‰Ià  H¨q¡LÑ1ˆIà�iÒÜÐPÓQÐQä�(‹O€Eàò ˆØ	�
‰
�4Õðð Ü�}‰}˜UÓ#ˆÜ�}‰}˜UÓ#ˆð �4Š<¡
Øð �>‰>˜$ Ó%Ð1¹+Øð 	
�
‰
�4˜ÔØ×ÑÓ (Ò*Øà€Hð# ó    c                 óv  — t        j                   «       }g }t        |«      D ]J  }t        |dz   |«      D ]6  }|j                  |«       |j                  |«       |j                  ||«       Œ8 ŒL t        || |z  «      D ]¸  }|j	                  |«       |j                  |«      |k  rYt        j                  |«      }	||	k(  r|sŒ1|j                  ||	«      r|sŒF|j                  ||	«       |j                  |«      |k  rŒY|j                  |«      D ]$  }	|j                  |«       |j                  |	«       Œ& Œº |S )a˜  
    Generates and returns a :py:class:`~altgraph.Graph.Graph` instance that
    will have *steps* \* *growth_num* nodes and a scale free (powerlaw)
    connectivity. Starting with a fully connected graph with *growth_num*
    nodes at every step *growth_num* nodes are added to the graph and are
    connected to existing nodes with a probability proportional to the degree
    of these existing nodes.
    r   )
r   r   Úappendr   r	   Ú
out_degreer
   r   r   Úout_nbrs)
ÚstepsÚ
growth_numr   r   ÚgraphÚstoreÚiÚjr   Únbrs
             r   Úgenerate_scale_free_graphr'   5   s3  € ô �K‰K‹M€Eð €EÜ�:Óò !ˆÜ�q˜1‘u˜jÓ)ò 	!ˆAØ�L‰L˜ŒOØ�L‰L˜ŒOØ�N‰N˜1˜aÕ ñ	!ð!ô �j %¨*Ñ"4Ó5ò ˆØ�‰�tÔØ×Ñ˜tÓ$ zÒ1Ü—-‘- Ó&ˆCð �sŠ{¡:Øð ×!Ñ! $¨Ô,±[Øà�N‰N˜4 Ô%ð ×Ñ˜tÓ$ zÓ1ð —>‘> $Ó'ò 	ˆCØ�L‰L˜ÔØ�L‰L˜Õñ	ðð& €Lr   c                 ó  — |ht        «       t        «       }}}t        ||fg«      }| j                  }| j                  }| j                  }	|r™|j                  «       \  }
} ||«      }|�$|D ]  } ||«      rŒ|j                  |«        n |}
 ||«      D ]J  } |	|«      }|
|ur|j                  |
|f«       ||vsŒ'|j                  |«       |j                  |
|f«       ŒL |rŒ™|D ��cg c]  \  }}||vsŒ||f‘Œ }}}|||fS c c}}w )aÄ  
    Perform a walk in a depth-first order starting
    at *head*.

    Returns (visited, removes, orphans).

    * visited: the set of visited nodes
    * removes: the list of nodes where the node
      data does not all *filters*
    * orphans: tuples of (last_good, node),
      where node is not in removes, is directly
      reachable from a node in *removes* and
      *last_good* is the closest upstream node that is not
      in *removes*.
    )Úsetr   Ú	node_dataÚ	out_edgesr   ÚpopÚaddr   )r"   r   ÚfiltersÚvisitedÚremovesÚorphansÚstackÚget_dataÚ	get_edgesÚget_tailÚ	last_goodr   ÚdataÚfiltfuncÚedger   ÚlgÚtls                     r   Úfilter_stackr<   `   s%  € ð" "& ¬«¬s«u�gˆW€GÜ�D˜$�<�.Ó!€EØ�‰€HØ—‘€IØ�z‰z€Há
ØŸ)™)›+‰ˆ	�4Ù˜‹~ˆØÐØ#ò !�Ù •~Ø—K‘K Ô%Ùð!ð
 !�	Ù˜d“Oò 	0ˆDÙ˜D“>ˆDØ Ñ$Ø—‘˜Y¨Ð-Ô.Ø˜7Ò"Ø—‘˜DÔ!Ø—‘˜i¨Ð.Õ/ð	0ò ð$ )0×E™H˜R °2¸WÒ3D��BŠxÐE€GÑEà�G˜WÐ$Ð$ùó Fs   Ã*DÃ7D)FF)
Ú__doc__r
   Úcollectionsr   Úaltgraphr   r   r   r'   r<   © r   r   ú<module>rA      s&   ðñó
 Ý ç &ó&óR(óV+%r   