ó
    …~i¸O  ã                   óP  • S r SSKrSSKrSSKJr  SSKrSSKJrJ	r	  / SQr
\R                  " SSS9\" SS/5      SS	 j5       5       r\	" S
5      \R                  " SSSS9SS j5       5       r\R                  " SSSS9SS j5       r\R                  " SSS9SS j5       r\R                  " SSS9SS j5       r\	" S
5      \R                  " SSS9SS j5       5       r\	" S
5      \R                  " SSS9SS j5       5       r\	" S
5      \R                  " SSS9SS j5       5       rS rg)z0
Generators and functions for bipartite graphs.
é    N)Úreduce)Únodes_or_numberÚpy_random_state)Úconfiguration_modelÚhavel_hakimi_graphÚreverse_havel_hakimi_graphÚalternating_havel_hakimi_graphÚpreferential_attachment_graphÚrandom_graphÚgnmk_random_graphÚcomplete_bipartite_graphT)ÚgraphsÚreturns_graphé   c                 óˆ  ^• [         R                  " SU5      nUR                  5       (       a  [         R                  " S5      eU u  pUu  nm[	        U [
        R                  5      (       a4  [	        U[
        R                  5      (       a  T Vs/ s H  oPU-   PM	     snmUR                  USS9  UR                  TSS9  [        U5      [        U5      [        T5      -   :w  a  [         R                  " S5      eUR                  U4S jU 5       5        S[        U5       S[        T5       S	3UR                  S
'   U$ s  snf )a°  Returns the complete bipartite graph `K_{n_1,n_2}`.

The graph is composed of two partitions with nodes 0 to (n1 - 1)
in the first and nodes n1 to (n1 + n2 - 1) in the second.
Each node in the first is connected to each node in the second.

Parameters
----------
n1, n2 : integer or iterable container of nodes
    If integers, nodes are from `range(n1)` and `range(n1, n1 + n2)`.
    If a container, the elements are the nodes.
create_using : NetworkX graph instance, (default: nx.Graph)
   Return graph of this type.

Notes
-----
Nodes are the integers 0 to `n1 + n2 - 1` unless either n1 or n2 are
containers of nodes. If only one of n1 or n2 are integers, that
integer is replaced by `range` of that integer.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.complete_bipartite_graph
r   úDirected Graph not supported©Ú	bipartiter   z,Inputs n1 and n2 must contain distinct nodesc              3   ó>   >#   • U  H  nT  H  o!U4v •  M
     M     g 7f©N© )Ú.0ÚuÚvÚbottoms      €Úe/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/bipartite/generators.pyÚ	<genexpr>Ú+complete_bipartite_graph.<locals>.<genexpr>A   s   øé € Ð9¢S ´&¨Q˜•V±&‘V¢Sùs   ƒzcomplete_bipartite_graph(z, Ú)Úname)ÚnxÚempty_graphÚis_directedÚNetworkXErrorÚ
isinstanceÚnumbersÚIntegralÚadd_nodes_fromÚlenÚadd_edges_fromÚgraph)Ún1Ún2Úcreate_usingÚGÚtopÚir   s         @r   r   r      s  ø€ ô: 	�Š�q˜,Ó'€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>à�G€BØ�J€BˆÜ�"”g×&Ñ&×'Ñ'¬J°r¼7×;KÑ;K×,LÑ,LÙ"(Ó)¢&˜Q�q”&¡&Ñ)ˆØ×Ñ�S AÐÑ&Ø×Ñ�V qÐÑ)Ü
ˆ1ƒv”�S“œC ›KÑ'Ó'Ü×ÒÐMÓNÐNØ×ÑÔ9¡SÓ9Ô9Ø1´#°c³(°¸2¼cÀ&»k¸]È!ÐL€A‡G�GˆF�OØ€Hùò *s   ÂD?é   Úbipartite_configuration_model)r    r   r   c                 ób  ^^• [         R                  " SU[         R                  S9nUR                  5       (       a  [         R                  " S5      e[        U 5      n[        U5      n[        U 5      n[        U5      nXx:X  d  [         R                  " SU SU 35      e[        XEU5      n[        U 5      S:X  d  [        U 5      S:X  a  U$ [        U5       V	s/ s H
  o™/X	   -  PM     n
n	U
 VVs/ s H  o»  H  oÌPM     M     snnm[        XUU-   5       V	s/ s H  o™/XU-
     -  PM     n
n	U
 VVs/ s H  o»  H  oÌPM     M     snnmUR                  T5        UR                  T5        UR                  UU4S j[        U5       5       5        SUl        U$ s  sn	f s  snnf s  sn	f s  snnf )a{  Returns a random bipartite graph from two given degree sequences.

Parameters
----------
aseq : list
   Degree sequence for node set A.
bseq : list
   Degree sequence for node set B.
create_using : NetworkX graph instance, optional
   Return graph of this type.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.

The graph is composed of two partitions. Set A has nodes 0 to
(len(aseq) - 1) and set B has nodes len(aseq) to (len(bseq) - 1).
Nodes from set A are connected to nodes in set B by choosing
randomly from the possible free stubs, one in A and one in B.

Notes
-----
The sum of the two sequences must be equal: sum(aseq)=sum(bseq)
If no graph type is specified use MultiGraph with parallel edges.
If you want a graph with no parallel edges use create_using=Graph()
but then the resulting degree sequences might not be exact.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.configuration_model
r   ©Údefaultr   ú/invalid degree sequences, sum(aseq)!=sum(bseq),Ú,c              3   ó8   >#   • U  H  nTU   TU   /v •  M     g 7fr   r   )r   r1   ÚastubsÚbstubss     €€r   r   Ú&configuration_model.<locals>.<genexpr>ˆ   s   øé € ÐA²[°�f˜Q‘i ¨¡Õ+²[ùs   ƒr3   )r!   r"   Ú
MultiGraphr#   r$   r)   ÚsumÚ_add_nodes_with_bipartite_labelÚmaxÚrangeÚshuffler*   r    )ÚaseqÚbseqr.   Úseedr/   ÚlenaÚlenbÚsumaÚsumbr   ÚstubsÚsubseqÚxr:   r;   s                @@r   r   r   F   s}  ù€ ôF 	�Š�q˜,´·±Ñ>€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>ô ˆt‹9€DÜˆt‹9€DÜˆt‹9€DÜˆt‹9€Dà‹<Ü×ÒØ=¸d¸VÀ1ÀTÀFÐKó
ð 	
ô 	(¨°Ó6€Aä
ˆ4ƒy�Aƒ~œ˜T› a›Øˆô %*¨$¤KÓ0¢K˜qˆS�4‘7Œ]¡K€EÐ0Ù#Ô4še�F«V¨Ša©V‰a™eÒ4€Fä+0°¸d±{Ô+CÓDÒ+C aˆS�4˜D™‘>Ô!Ñ+C€EÐDÙ#Ô4še�F«V¨Ša©V‰a™eÒ4€Fð 	‡L�L�ÔØ‡L�L�Ôà×ÑÕA´U¸4´[ÓAÔAà,€A„FØ€Hùò 1ùÛ4ùâDùÛ4s   ÃFÃ0F ÄF&Ä3F+Úbipartite_havel_hakimi_graphc                 óf  • [         R                  " SU[         R                  S9nUR                  5       (       a  [         R                  " S5      e[        U 5      n[        U5      n[        U 5      n[        U5      nXg:X  d  [         R                  " SU SU 35      e[        X4U5      n[        U 5      S:X  d  [        U 5      S:X  a  U$ [        U5       Vs/ s H	  o€U   U/PM     n	n[        XDU-   5       Vs/ s H  o�X„-
     U/PM     n
nU	R                  5         U	(       a}  U	R                  5       u  p¼US:X  a  OdU
R                  5         X«* S  HB  nUS   nUR                  XÈ5        US==   S-  ss'   US   S:X  d  M1  U
R                  U5        MD     U	(       a  M}  SUl        U$ s  snf s  snf )	aE  Returns a bipartite graph from two given degree sequences using a
Havel-Hakimi style construction.

The graph is composed of two partitions. Set A has nodes 0 to
(len(aseq) - 1) and set B has nodes len(aseq) to (len(bseq) - 1).
Nodes from the set A are connected to nodes in the set B by
connecting the highest degree nodes in set A to the highest degree
nodes in set B until all stubs are connected.

Parameters
----------
aseq : list
   Degree sequence for node set A.
bseq : list
   Degree sequence for node set B.
create_using : NetworkX graph instance, optional
   Return graph of this type.

Notes
-----
The sum of the two sequences must be equal: sum(aseq)=sum(bseq)
If no graph type is specified use MultiGraph with parallel edges.
If you want a graph with no parallel edges use create_using=Graph()
but then the resulting degree sequences might not be exact.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.havel_hakimi_graph
r   r5   r   r7   r8   Nr   rM   ©r!   r"   r=   r#   r$   r)   r>   r?   r@   rA   ÚsortÚpopÚadd_edgeÚremover    )rC   rD   r.   r/   ÚnaseqÚnbseqrH   rI   r   r:   r;   Údegreer   Útargets                 r   r   r   Ž   s‰  € ôB 	�Š�q˜,´·±Ñ>€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>ô �‹I€EÜ�‹I€Eäˆt‹9€DÜˆt‹9€Dà‹<Ü×ÒØ=¸d¸VÀ1ÀTÀFÐKó
ð 	
ô 	(¨°%Ó8€Aä
ˆ4ƒy�Aƒ~œ˜T› a›Øˆô %*¨%¤LÓ1¢L˜q�A‰w˜‹l¡L€FÐ1Ü,1°%À¹Ô,GÓHÒ,G q�A‘I‰ Ó"Ñ,G€FÐHØ
‡K�K„MÞ
Ø—j‘j“l‰ˆØ�Q‹;Øà�‰ŒØ˜W˜XÓ&ˆFØ�q‘	ˆAØ�J‰J�qÔØ�1‹I˜‰N‹IØ�a‰y˜A�~Ø—‘˜fÖ%ñ '÷ ˆ&ð ,€A„FØ€Hùò# 2ùÚHó   ÃF)Ã8F.c                 óf  • [         R                  " SU[         R                  S9nUR                  5       (       a  [         R                  " S5      e[        U 5      n[        U5      n[        U 5      n[        U5      nXg:X  d  [         R                  " SU SU 35      e[        X4U5      n[        U 5      S:X  d  [        U 5      S:X  a  U$ [        U5       Vs/ s H	  o€U   U/PM     n	n[        XDU-   5       Vs/ s H  o�X„-
     U/PM     n
nU	R                  5         U
R                  5         U	(       am  U	R                  5       u  p¼US:X  a  OTU
SU  HB  nUS   nUR                  XÈ5        US==   S-  ss'   US   S:X  d  M1  U
R                  U5        MD     U	(       a  Mm  SUl        U$ s  snf s  snf )aH  Returns a bipartite graph from two given degree sequences using a
Havel-Hakimi style construction.

The graph is composed of two partitions. Set A has nodes 0 to
(len(aseq) - 1) and set B has nodes len(aseq) to (len(bseq) - 1).
Nodes from set A are connected to nodes in the set B by connecting
the highest degree nodes in set A to the lowest degree nodes in
set B until all stubs are connected.

Parameters
----------
aseq : list
   Degree sequence for node set A.
bseq : list
   Degree sequence for node set B.
create_using : NetworkX graph instance, optional
   Return graph of this type.

Notes
-----
The sum of the two sequences must be equal: sum(aseq)=sum(bseq)
If no graph type is specified use MultiGraph with parallel edges.
If you want a graph with no parallel edges use create_using=Graph()
but then the resulting degree sequences might not be exact.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.reverse_havel_hakimi_graph
r   r5   r   r7   r8   r   Ú$bipartite_reverse_havel_hakimi_graphrO   )rC   rD   r.   r/   rF   rG   rH   rI   r   r:   r;   rV   r   rW   s                 r   r   r   Ù   s‰  € ôB 	�Š�q˜,´·±Ñ>€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>ô ˆt‹9€DÜˆt‹9€DÜˆt‹9€DÜˆt‹9€Dà‹<Ü×ÒØ=¸d¸VÀ1ÀTÀFÐKó
ð 	
ô 	(¨°Ó6€Aä
ˆ4ƒy�Aƒ~œ˜T› a›Øˆô %*¨$¤KÓ0¢K˜q�A‰w˜‹l¡K€FÐ0Ü+0°¸d±{Ô+CÓDÒ+C a�A‘H‰~˜qÓ!Ñ+C€FÐDØ
‡K�K„MØ
‡K�K„MÞ
Ø—j‘j“l‰ˆØ�Q‹;Øà˜Q˜vÓ&ˆFØ�q‘	ˆAØ�J‰J�qÔØ�1‹I˜‰N‹IØ�a‰y˜A�~Ø—‘˜fÖ%ñ '÷ ˆ&ð 4€A„FØ€Hùò# 1ùÚDrX   c                 óh  • [         R                  " SU[         R                  S9nUR                  5       (       a  [         R                  " S5      e[        U 5      n[        U5      n[        U 5      n[        U5      nXg:X  d  [         R                  " SU SU 35      e[        X4U5      n[        U 5      S:X  d  [        U 5      S:X  a  U$ [        U5       Vs/ s H	  o€U   U/PM     n	n[        XDU-   5       Vs/ s H  o�X„-
     U/PM     n
nU	(       Ga  U	R                  5         U	R                  5       u  p¼US:X  a  OÞU
R                  5         U
SUS-   nX«* US-  -   S n[        Xí5       VVs/ s H  oÿ  H  nUPM     M     nnn[        U5      [        U5      [        U5      -   :  a  UR                  UR                  5       5        U HB  nUS   nUR                  XÈ5        US==   S-  ss'   US   S:X  d  M1  U
R                  U5        MD     U	(       a  GM  S	Ul        U$ s  snf s  snf s  snnf )
a{  Returns a bipartite graph from two given degree sequences using
an alternating Havel-Hakimi style construction.

The graph is composed of two partitions. Set A has nodes 0 to
(len(aseq) - 1) and set B has nodes len(aseq) to (len(bseq) - 1).
Nodes from the set A are connected to nodes in the set B by
connecting the highest degree nodes in set A to alternatively the
highest and the lowest degree nodes in set B until all stubs are
connected.

Parameters
----------
aseq : list
   Degree sequence for node set A.
bseq : list
   Degree sequence for node set B.
create_using : NetworkX graph instance, optional
   Return graph of this type.

Notes
-----
The sum of the two sequences must be equal: sum(aseq)=sum(bseq)
If no graph type is specified use MultiGraph with parallel edges.
If you want a graph with no parallel edges use create_using=Graph()
but then the resulting degree sequences might not be exact.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.alternating_havel_hakimi_graph
r   r5   r   r7   r8   é   Nr   Ú(bipartite_alternating_havel_hakimi_graph)r!   r"   r=   r#   r$   r)   r>   r?   r@   rA   rP   rQ   ÚzipÚappendrR   rS   r    )rC   rD   r.   r/   rT   rU   rH   rI   r   r:   r;   rV   r   ÚsmallÚlargeÚzrL   rJ   rW   s                      r   r	   r	   #  sù  € ôD 	�Š�q˜,´·±Ñ>€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>ô �‹I€EÜ�‹I€EÜˆt‹9€DÜˆt‹9€Dà‹<Ü×ÒØ=¸d¸VÀ1ÀTÀFÐKó
ð 	
ô 	(¨°%Ó8€Aä
ˆ4ƒy�Aƒ~œ˜T› a›Øˆä$)¨%¤LÓ1¢L˜q�A‰w˜‹l¡L€FÐ1Ü,1°%À¹Ô,GÓHÒ,G q�A‘I‰ Ó"Ñ,G€FÐHß
Ø�‰ŒØ—j‘j“l‰ˆØ�Q‹;ØØ�‰ŒØ�q˜6 Q™;Ð'ˆØ˜ &¨A¡+Ñ-Ð0Ð1ˆÜ Ô-Ô9Ò-�q³q°!“±q‘Ñ-ˆÑ9Üˆu‹:œ˜E›
¤S¨£ZÑ/Ó/Ø�L‰L˜Ÿ™›Ô%ÛˆFØ�q‘	ˆAØ�J‰J�qÔØ�1‹I˜‰N‹IØ�a‰y˜A�~Ø—‘˜fÖ%ñ ÷ ‰&ð$ 8€A„FØ€Hùò+ 2ùÚHùó :s   ÃH$Ã8H)Å.H.c                 ó°  • [         R                  " SU[         R                  S9nUR                  5       (       a  [         R                  " S5      eUS:”  a  [         R                  " SU S35      e[        U 5      n[        XES5      n[        U5       Vs/ s H
  of/X   -  PM     nnU(       Ga  US   (       aî  US   S   nUS   R                  U5        UR                  5       U:  d  [        U5      U:X  a-  [        U5      n	UR                  U	SS9  UR                  X‰5        Ov[        U[        U5      5       V
s/ s H  oª/UR                  U
5      -  PM     nn
[        S U5      nUR                  U5      n	UR                  U	SS9  UR                  X‰5        US   (       a  Mî  UR                  US   5        U(       a  GM  S	Ul        U$ s  snf s  sn
f )
aÞ  Create a bipartite graph with a preferential attachment model from
a given single degree sequence.

The graph is composed of two partitions. Set A has nodes 0 to
(len(aseq) - 1) and set B has nodes starting with node len(aseq).
The number of nodes in set B is random.

Parameters
----------
aseq : list
   Degree sequence for node set A.
p :  float
   Probability that a new bottom node is added.
create_using : NetworkX graph instance, optional
   Return graph of this type.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.

References
----------
.. [1] Guillaume, J.L. and Latapy, M.,
   Bipartite graphs as models of complex networks.
   Physica A: Statistical Mechanics and its Applications,
   2006, 371(2), pp.795-813.
.. [2] Jean-Loup Guillaume and Matthieu Latapy,
   Bipartite structure of all complex networks,
   Inf. Process. Lett. 90, 2004, pg. 215-221
   https://doi.org/10.1016/j.ipl.2004.03.007

Notes
-----
The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.preferential_attachment_graph
r   r5   r   r   zprobability z > 1r   c                 ó
   • X-   $ r   r   )rL   Úys     r   Ú<lambda>Ú/preferential_attachment_graph.<locals>.<lambda>¯  s   € ¨aªeó    Ú'bipartite_preferential_attachment_model)r!   r"   r=   r#   r$   r)   r?   rA   rS   ÚrandomÚadd_noderR   rV   r   Úchoicer    )rC   Úpr.   rE   r/   rT   r   ÚvvÚsourcerW   ÚbÚbbÚbbstubss                r   r
   r
   q  s’  € ôR 	�Š�q˜,´·±Ñ>€AØ‡}�}‡�Ü×ÒÐ=Ó>Ð>àˆ1ƒuÜ×Ò ¨a¨S°Ð5Ó6Ð6ä�‹I€EÜ'¨°!Ó4€AÜ!& u¤Ó	.¢˜Aˆ#�‘Œ-¡€BÐ	.ß
Ø��eØ˜‘U˜1‘XˆFØˆq‰E�L‰L˜Ô Ø�{‰{‹}˜qÓ ¤C¨£F¨e£OÜ˜Q›�Ø—
‘
˜6¨Q�
Ñ/Ø—
‘
˜6Õ*ä16°u¼cÀ!»fÔ1EÓFÒ1E¨A�c˜AŸH™H Q›KÔ'Ñ1E�ÐFä Ñ!3°RÓ8�àŸ™ WÓ-�Ø—
‘
˜6¨Q�
Ñ/Ø—
‘
˜6Ô*ð ��e‰eð 	�	‰	�"�Q‘%Ô÷! ‰"ð" 7€A„FØ€Hùò' 
/ùò Gs   ÂGÄ<Gc                 ó4  • [         R                  " 5       n[        XPU5      nU(       a  [         R                  " U5      nSU  SU SU S3Ul        US::  a  U$ US:¼  a  [         R
                  " X5      $ [        R                  " SU-
  5      nSnSnXp:  ay  [        R                  " SUR                  5       -
  5      n	US-   [        X–-  5      -   nX�:¼  a  Xp:  a  X�-
  nUS-   nX�:¼  a  Xp:  a  M  Xp:  a  UR                  XpU-   5        Xp:  a  My  U(       a‚  SnSnXp:  ay  [        R                  " SUR                  5       -
  5      n	US-   [        X–-  5      -   nX�:¼  a  Xp:  a  X�-
  nUS-   nX�:¼  a  Xp:  a  M  Xp:  a  UR                  X-   U5        Xp:  a  My  U$ )uç  Returns a bipartite random graph.

This is a bipartite version of the binomial (ErdÅ‘s-RÃ©nyi) graph.
The graph is composed of two partitions. Set A has nodes 0 to
(n - 1) and set B has nodes n to (n + m - 1).

Parameters
----------
n : int
    The number of nodes in the first bipartite set.
m : int
    The number of nodes in the second bipartite set.
p : float
    Probability for edge creation.
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
directed : bool, optional (default=False)
    If True return a directed graph

Notes
-----
The bipartite random graph algorithm chooses each of the n*m (undirected)
or 2*nm (directed) possible edges with probability p.

This algorithm is $O(n+m)$ where $m$ is the expected number of edges.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.random_graph

See Also
--------
gnp_random_graph, configuration_model

References
----------
.. [1] Vladimir Batagelj and Ulrik Brandes,
   "Efficient generation of large random networks",
   Phys. Rev. E, 71, 036113, 2005.
zfast_gnp_random_graph(r8   r   r   r   g      ð?éÿÿÿÿ)r!   ÚGraphr?   ÚDiGraphr    r   ÚmathÚlogrj   ÚintrR   )
ÚnÚmrm   rE   Údirectedr/   Úlpr   ÚwÚlrs
             r   r   r   ¹  sˆ  € ô\ 	�Š‹
€AÜ'¨¨aÓ0€AÞÜ�JŠJ�q‹MˆØ% a S¨¨!¨¨A¨a¨S°Ð2€A„FàˆAƒvØˆØˆAƒvÜ×*Ò*¨1Ó0Ð0ä	�Š�#˜‘'Ó	€Bà	€AØ
€AØ
‹%Ü�XŠX�c˜DŸK™K›MÑ)Ó*ˆØ�‰E”C˜™“LÑ ˆØ‹f˜›Ø‘ˆAØ�A‘ˆAð ‹f˜�ð ‹5Ø�J‰J�q˜a™%Ô ð �%ö ð ˆØˆØ‹eÜ—’˜# §¡£Ñ-Ó.ˆBØ�A‘œ˜B™G›Ñ$ˆAØ“&˜Q›UØ‘E�Ø˜‘E�ð “&˜Q�Uð ‹uØ—
‘
˜1™5 !Ô$ð �eð €Hrh   c                 óD  • [         R                  " 5       n[        XPU5      nU(       a  [         R                  " U5      nSU  SU SU S3Ul        U S:X  d  US:X  a  U$ X-  nX&:¼  a  [         R
                  " XUS9$ UR                  SS9 V Vs/ s H  u  pUS   S	:X  d  M  U PM     nn n[        [        U5      [        U5      -
  5      n	S	n
X¢:  aI  UR                  U5      nUR                  U	5      nXÅU   ;   a  M1  UR                  X¼5        U
S-  n
X¢:  a  MI  U$ s  snn f )
aq  Returns a random bipartite graph G_{n,m,k}.

Produces a bipartite graph chosen randomly out of the set of all graphs
with n top nodes, m bottom nodes, and k edges.
The graph is composed of two sets of nodes.
Set A has nodes 0 to (n - 1) and set B has nodes n to (n + m - 1).

Parameters
----------
n : int
    The number of nodes in the first bipartite set.
m : int
    The number of nodes in the second bipartite set.
k : int
    The number of edges
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
directed : bool, optional (default=False)
    If True return a directed graph

Examples
--------
>>> G = nx.bipartite.gnmk_random_graph(10, 20, 50)

See Also
--------
gnm_random_graph

Notes
-----
If k > m * n then a complete bipartite graph is returned.

This graph is a bipartite version of the `G_{nm}` random graph model.

The nodes are assigned the attribute 'bipartite' with the value 0 or 1
to indicate which bipartite set the node belongs to.

This function is not imported in the main namespace.
To use it use nx.bipartite.gnmk_random_graph
zbipartite_gnm_random_graph(r8   r   r   )r.   T)Údatar   r   )r!   ru   r?   rv   r    r   ÚnodesÚlistÚsetrl   rR   )rz   r{   ÚkrE   r|   r/   Ú	max_edgesÚdr0   r   Ú
edge_countr   r   s                r   r   r     s  € ôX 	�Š‹
€AÜ'¨¨aÓ0€AÞÜ�JŠJ�q‹MˆØ*¨1¨#¨Q¨q¨c°°1°#°QÐ7€A„FØˆAƒv��a“ØˆØ‘€IØƒ~Ü×*Ò*¨1¸aÑ@Ð@àŸ™ d˜Ñ+Ô
CÒ+‘�¨q°©~ÀÑ/B�1Ñ+€CÑ
CÜ”#�a“&œ3˜s›8Ñ#Ó$€FØ€JØ
‹.à�K‰K˜ÓˆØ�K‰K˜ÓˆØ�!‘‹9Ùà�J‰J�qÔØ˜!‰OˆJð �.ð €Hùó Ds   ÂDÂ!Dc                 ó  • U R                  [        X-   5      5        [        [        [        U5      S/U-  5      5      nUR	                  [        [        [        XU-   5      S/U-  5      5      5        [
        R                  " XS5        U $ )Nr   r   r   )r(   rA   Údictr^   Úupdater!   Úset_node_attributes)r/   rF   rG   rp   s       r   r?   r?   V  sn   € Ø×Ñ”U˜4™;Ó'Ô(ÜŒS”�t“˜q˜c D™jÓ)Ó*€AØ‡H�HŒT”#”e˜D¨¡+Ó.°°°d±
Ó;Ó<Ô=Ü×Ò˜1 Ô-Ø€Hrh   r   )NN)NF)Ú__doc__rw   r&   Ú	functoolsr   Únetworkxr!   Únetworkx.utilsr   r   Ú__all__Ú_dispatchabler   r   r   r   r	   r
   r   r   r?   r   rh   r   Ú<module>r“      s”  ðñó Û Ý ã ß ;ò	€ð ×Ò˜¨TÑ2Ù�!�Q�Óó)ó ó 3ð)ñX �ÓØ×ÒÐ6¸tÐSWÑXóCó Yó ðCðL ×ÒÐ5¸dÐRVÑWóGó XðGðT ×Ò˜¨TÑ2óFó 3ðFðR ×Ò˜¨TÑ2óJó 3ðJñZ �ÓØ×Ò˜¨TÑ2óCó 3ó ðCñL �ÓØ×Ò˜¨TÑ2óRó 3ó ðRñj �ÓØ×Ò˜¨TÑ2óAó 3ó ðAóHrh   