+
    )i                         R t ^ RIt^ RIHt ^ RIHt ^ RIHt RR.t	]! ^4      ]P                  ! RRR7      RR	R/R
 ll4       4       t]! ^4      ]P                  ! RRR7      RR	R/R ll4       4       tR# )zFunctions for generating graphs based on the "duplication" method.

These graph generators start with a small initial graph then duplicate
nodes and (partially) duplicate their edges. These functions are
generally inspired by biological networks.

N)NetworkXError)py_random_state)check_create_usingpartial_duplication_graphduplication_divergence_graphT)graphsreturns_graphcreate_usingc               &   \        VRRR7      pV^ 8  g   V^8  g   V^ 8  g   V^8  d   Rp\        V4      hW8  d   \        R4      h\        P                  ! W4      p\	        W4       F  pVP                  ^ V^,
          4      p	VP                  V4       \        \        P                  ! Wy4      4       F+  p
VP                  4       V8  g   K  VP                  W4       K-  	  VP                  4       V8  g   K  VP                  W4       K  	  V# )a!  Returns a random graph using the partial duplication model.

Parameters
----------
N : int
    The total number of nodes in the final graph.

n : int
    The number of nodes in the initial clique.

p : float
    The probability of joining each neighbor of a node to the
    duplicate node. Must be a number in the between zero and one,
    inclusive.

q : float
    The probability of joining the source node to the duplicate
    node. Must be a number in the between zero and one, inclusive.

seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.

create_using : Graph constructor, optional (default=nx.Graph)
    Graph type to create. If graph instance, then cleared before populated.
    Multigraph and directed types are not supported and raise a ``NetworkXError``.

Notes
-----
A graph of nodes is grown by creating a fully connected graph
of size `n`. The following procedure is then repeated until
a total of `N` nodes have been reached.

1. A random node, *u*, is picked and a new node, *v*, is created.
2. For each neighbor of *u* an edge from the neighbor to *v* is created
   with probability `p`.
3. An edge from *u* to *v* is created with probability `q`.

This algorithm appears in [1].

This implementation allows the possibility of generating
disconnected graphs.

References
----------
.. [1] Knudsen Michael, and Carsten Wiuf. "A Markov chain approach to
       randomly grown graphs." Journal of Applied Mathematics 2008.
       <https://doi.org/10.1155/2008/190836>

Fdirected
multigraphz3partial duplication graph must have 0 <= p, q <= 1.z+partial duplication graph must have n <= N.)r   r   nxcomplete_graphrangerandintadd_nodelistall_neighborsrandomadd_edge)Nnpqseedr	   msgGnew_nodesrc_nodenbr_nodes   &&&&&$     ]/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/generators/duplication.pyr   r      s    j &lUuUL1uAQ!a%CC  uIJJ
!*A!K<<8a<0 	


8 R--a:;H{{}q 

8. < ;;=1JJx*    H    c               @   V^8  g   V^ 8  d   RV R2p\         P                  ! V4      hV ^8  d   Rp\         P                  ! V4      h\        VRRR7      p\         P                  ! VR7      pVP	                  ^ ^4       ^pW`8  d   VP                  \        V4      4      pVP                  V4       RpVP                  V4       F-  p	VP                  4       V8  g   K  VP	                  Wi4       RpK/  	  V'       g   VP                  V4       K  V^,          pK  V# )a  Returns an undirected graph using the duplication-divergence model.

A graph of `n` nodes is created by duplicating the initial nodes
and retaining edges incident to the original nodes with a retention
probability `p`.

Parameters
----------
n : int
    The desired number of nodes in the graph.
p : float
    The probability for retaining the edge of the replicated node.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
create_using : Graph constructor, optional (default=nx.Graph)
    Graph type to create. If graph instance, then cleared before populated.
    Multigraph and directed types are not supported and raise a ``NetworkXError``.

Returns
-------
G : Graph

Raises
------
NetworkXError
    If `p` is not a valid probability.
    If `n` is less than 2.

Notes
-----
This algorithm appears in [1].

This implementation disallows the possibility of generating
disconnected graphs.

References
----------
.. [1] I. Ispolatov, P. L. Krapivsky, A. Yuryev,
   "Duplication-divergence model of protein interaction network",
   Phys. Rev. E, 71, 061911, 2005.

zNetworkXError p=z is not in [0,1].z$n must be greater than or equal to 2Fr   )r	   T)r   r   r   empty_graphr   choicer   r   	neighborsr   remove_node)
r   r   r   r	   r   r   irandom_nodeflagnbrs
   &&&$      r!   r   r   a   s    \ 	1uA #45s##1u4s##%lUuUL
L1A JJq!	A
%kk$q'*	

1;;{+C{{}q 

1"	 ,
 MM! FAHr"   )N)__doc__networkxr   networkx.exceptionr   networkx.utilsr   networkx.utils.miscr   __all___dispatchabler   r    r"   r!   <module>r4      s     , * 2&(F
G T2KT K 3 K\ T2K$ K 3 Kr"   