+
    �°³js2  ã                   ó´  € R t ^ RIt^ RIt^ RIHt ^ RIHtHt . ROt	 ! R R]P                  4      t]! R4      ]! R4      ]P                  R 4       4       4       t]P                  ]P                  3R	 l4       t]P                  R
 4       t]P                  R 4       tR tR tR]P                  3R lt]! R4      ]P                  ! RR7      R 4       4       tR# )zÇ
Algorithms for chordal graphs.

A graph is chordal if every cycle of length at least 4 has a chord
(an edge joining two nodes not adjacent in the cycle).
https://en.wikipedia.org/wiki/Chordal_graph
N)Úconnected_components)Úarbitrary_elementÚnot_implemented_forÚNetworkXTreewidthBoundExceededc                   ó   € ] tR t^tRtRtR# )r   zRException raised when a treewidth bound has been provided and it has
been exceeded© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/chordal.pyr   r      s   † õr   ÚdirectedÚ
multigraphc                óh   € \        V P                  4      ^8:  d   R# \        \        V 4      4      ^ 8H  # )ul  Checks whether G is a chordal graph.

A graph is chordal if every cycle of length at least 4 has a chord
(an edge joining two nodes not adjacent in the cycle).

Parameters
----------
G : graph
  A NetworkX graph.

Returns
-------
chordal : bool
  True if G is a chordal graph and False otherwise.

Raises
------
NetworkXNotImplemented
    The algorithm does not support DiGraph, MultiGraph and MultiDiGraph.

Examples
--------
>>> e = [
...     (1, 2),
...     (1, 3),
...     (2, 3),
...     (2, 4),
...     (3, 4),
...     (3, 5),
...     (3, 6),
...     (4, 5),
...     (4, 6),
...     (5, 6),
... ]
>>> G = nx.Graph(e)
>>> nx.is_chordal(G)
True

Notes
-----
The routine tries to go through every node following maximum cardinality
search. It returns False when it finds that the separator for any node
is not a clique.  Based on the algorithms in [1]_.

Self loops are ignored.

References
----------
.. [1] R. E. Tarjan and M. Yannakakis, Simple linear-time algorithms
   to test chordality of graphs, test acyclicity of hypergraphs, and
   selectively reduce acyclic hypergraphs, SIAM J. Comput., 13 (1984),
   pp. 566â€“579.
T)ÚlenÚnodesÚ_find_chordality_breaker©ÚGs   &r   Ú
is_chordalr      s.   € ôr ˆ1�7‰7ƒ|�qÔÙÜÔ'¨Ó*Ó+¨qÑ0Ð0r   c                ó.  € \        V 4      '       g   \        P                  ! R4      h\        P                  ! V 4      pVP	                  W4       \        4       p\        WAV4      pV'       dG   Vw  rxp	VP                  V4       V F  p
W¡8w  g   K  VP	                  W4       K  	  \        WAV4      pKN  V'       d[   VP                  V4       W,           F=  p\        V\        W,          4      ,          4      ^8X  g   K+  VP                  V4        V# 	  V# )a!  Returns the set of induced nodes in the path from s to t.

Parameters
----------
G : graph
  A chordal NetworkX graph
s : node
    Source node to look for induced nodes
t : node
    Destination node to look for induced nodes
treewidth_bound: float
    Maximum treewidth acceptable for the graph H. The search
    for induced nodes will end as soon as the treewidth_bound is exceeded.

Returns
-------
induced_nodes : Set of nodes
    The set of induced nodes in the path from s to t in G

Raises
------
NetworkXError
    The algorithm does not support DiGraph, MultiGraph and MultiDiGraph.
    If the input graph is an instance of one of these classes, a
    :exc:`NetworkXError` is raised.
    The algorithm can only be applied to chordal graphs. If the input
    graph is found to be non-chordal, a :exc:`NetworkXError` is raised.

Examples
--------
>>> G = nx.Graph()
>>> G = nx.generators.classic.path_graph(10)
>>> induced_nodes = nx.find_induced_nodes(G, 1, 9, 2)
>>> sorted(induced_nodes)
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Notes
-----
G must be a chordal graph and (s,t) an edge that is not in G.

If a treewidth_bound is provided, the search for induced nodes will end
as soon as the treewidth_bound is exceeded.

The algorithm is inspired by Algorithm 4 in [1]_.
A formal definition of induced node can also be found on that reference.

Self Loops are ignored

References
----------
.. [1] Learning Bounded Treewidth Bayesian Networks.
   Gal Elidan, Stephen Gould; JMLR, 9(Dec):2699--2731, 2008.
   http://jmlr.csail.mit.edu/papers/volume9/elidan08a/elidan08a.pdf
úInput graph is not chordal.)
r   ÚnxÚNetworkXErrorÚGraphÚadd_edgeÚsetr   ÚupdateÚaddr   )r   ÚsÚtÚtreewidth_boundÚHÚinduced_nodesÚtripletÚuÚvÚwÚns   &&&&       r   Úfind_induced_nodesr,   \   så   € ôp �a�=Š=Ü×ÒÐ<Ó=Ð=ä
�Š�‹€AØ‡J�JˆqÔÜ“E€MÜ& q¨_Ó=€Gß
Ø‰	ˆˆqØ×Ñ˜WÔ%ÛˆAØŽvØ—
‘
˜1Ö ñ ô +¨1°ÓAŠßà×Ñ˜!ÔØ—�ˆAÜ�=¤3 q¥t£9Õ,Ó-°Ö2Ø×!Ñ! !Ô$ØØÐñ	 ð Ðr   c              #  ó  a a"  € V 3R l\        S 4       4        EFl  pVP                  4       ^8X  dO   \        P                  ! V4      ^ 8”  d   \        P                  ! R4      h\        VP                  4       4      x € Kg  \        VP                  4       4      p\        V4      pVP                  V4       V0oV0pV'       d¶   \        VV V3R lR7      pVP                  V4       SP                  V4       \        VP                  V4      4      S,          pVP                  V4      p\        V4      '       d)   VP                  V4       WT8¼  g   \        V4      x € TpK§  \        P                  ! R4      h\        V4      x € EKo  	  R# 5i)a½  Returns all maximal cliques of a chordal graph.

The algorithm breaks the graph in connected components and performs a
maximum cardinality search in each component to get the cliques.

Parameters
----------
G : graph
  A NetworkX graph

Yields
------
frozenset of nodes
    Maximal cliques, each of which is a frozenset of
    nodes in `G`. The order of cliques is arbitrary.

Raises
------
NetworkXError
    The algorithm does not support DiGraph, MultiGraph and MultiDiGraph.
    The algorithm can only be applied to chordal graphs. If the input
    graph is found to be non-chordal, a :exc:`NetworkXError` is raised.

Examples
--------
>>> e = [
...     (1, 2),
...     (1, 3),
...     (2, 3),
...     (2, 4),
...     (3, 4),
...     (3, 5),
...     (3, 6),
...     (4, 5),
...     (4, 6),
...     (5, 6),
...     (7, 8),
... ]
>>> G = nx.Graph(e)
>>> G.add_node(9)
>>> cliques = [c for c in chordal_graph_cliques(G)]
>>> cliques[0]
frozenset({1, 2, 3})
c              3   ób   <"  € T F$  pSP                  V4      P                  4       x € K&  	  R # 5i©N)ÚsubgraphÚcopy)Ú.0Úcr   s   & €r   Ú	<genexpr>Ú(chordal_graph_cliques.<locals>.<genexpr>Ú   s'   øé € ÐDÑ,C qˆa�j‰j˜‹m× Ñ ×"Ð"Ó,Cùs   ƒ,/r   c                 óf   <€ \        SP                  V ,          P                  4       S,          4      # r/   ©r   Ú_adjÚkeys©r+   r   Únumbereds   &€€r   Ú<lambda>Ú'chordal_graph_cliques.<locals>.<lambda>è   s   ø€ ´#°a·f±f¸Qµi·n±nÓ6FÈÕ6QÔ2Rr   ©ÚkeyN)r   Únumber_of_nodesr   Únumber_of_selfloopsr   Ú	frozensetr   r   r   ÚremoveÚmaxr!   Ú	neighborsr0   Ú_is_complete_graph)r   ÚCÚ
unnumberedr)   Úclique_wanna_beÚnew_clique_wanna_beÚsgr;   s   f      @r   Úchordal_graph_cliquesrL   ¬   s9  ùé € ô\ EÔ,@ÀÔ,C×DˆØ×ÑÓ !Ô#Ü×%Ò% aÓ(¨1Ô,Ü×&Ò&Ð'DÓEÐEÜ˜AŸG™G›IÓ&Ô&ä˜QŸW™W›Y›ˆJÜ! !Ó$ˆAØ×Ñ˜aÔ Ø�sˆHØ ˜cˆOßô ˜
Õ(RÔS�Ø×!Ñ! !Ô$Ø—‘˜Q”Ü&)¨!¯+©+°a«.Ó&9¸HÕ&DÐ#Ø—Z‘Z Ó0�Ü% b×)Ò)Ø'×+Ñ+¨AÔ.Ø.ÔAÜ'¨Ó8Ò8Ø&9’Oä×*Ò*Ð+HÓIÐIÜ˜OÓ,Õ,ó5 Eùs   „B?FÃC	Fc                óº   € \        V 4      '       g   \        P                  ! R4      h\        \	        \        P
                  ! V 4      \        R7      4      ^,
          # )a?  Returns the treewidth of the chordal graph `G`.

Parameters
----------
G : graph
    A chordal graph.

Returns
-------
treewidth : int
    The size of the largest clique in the graph minus one.

Raises
------
NetworkXError
    If `G` is not chordal.

Examples
--------
>>> G = nx.barbell_graph(4, 6)
>>> nx.chordal_graph_treewidth(G)
3

See Also
--------
networkx.algorithms.approximation.treewidth.treewidth_min_degree
networkx.algorithms.approximation.treewidth.treewidth_min_fill_in

References
----------
.. [1] https://en.wikipedia.org/wiki/Tree_decomposition#Treewidth
r   r>   )r   r   r   r   rD   rL   r   s   &r   Úchordal_graph_treewidthrN   ÷   sB   € ôD �a�=Š=Ü×ÒÐ<Ó=Ð=äŒs”2×+Ò+¨AÓ.´CÔ8Ó9¸AÕ=Ð=r   c                óê   € \         P                  ! V 4      ^ 8”  d   \         P                  ! R4      hV P                  4       pV^8  d   R# V P	                  4       pW^,
          ,          ^,          pW#8H  # )z&Returns True if G is a complete graph.z'Self loop found in _is_complete_graph()T)r   rA   r   r@   Únumber_of_edges)r   r+   ÚeÚ	max_edgess   &   r   rF   rF     se   € ä	×Ò˜aÓ  1Ô$Ü×ÒÐHÓIÐIØ	×ÑÓ€AØˆ1„uÙØ	×ÑÓ€AØ˜!•e• Õ!€IØ‰>Ðr   c                óÒ   € \        V 4      pV  FU  pV\        \        W,          P                  4       4      V.,           4      ,
          pV'       g   KD  W#P                  4       3u # 	  R# )z5Given a non-complete graph G, returns a missing edge.N)r   Úlistr9   Úpop)r   r   r(   Úmissings   &   r   Ú_find_missing_edgerW   +  sL   € ä�‹F€EÛˆØœ#œd 1¥4§9¡9£;Ó/°1°#Õ5Ó6Õ6ˆß‰7Ø—{‘{“}Ð%Ò%ó r   c                ó2  a a
€ \        S 4      ^ 8X  d   \        P                  ! R4      h\        S 4      pVf   \	        S 4      pVP                  V4       V0o
RpV'       d·   \        VV V
3R lR7      pVP                  V4       S
P                  V4       \        S V,          4      S
,          pS P                  V4      p\        V4      '       d7   \        V\        V4      4      pWB8”  d   \        P                  ! RV 24      hK­  \        V4      w  r‰W…V	3# R# )a/  Given a graph G, starts a max cardinality search
(starting from s if s is given and from an arbitrary node otherwise)
trying to find a non-chordal cycle.

If it does find one, it returns (u,v,w) where u,v,w are the three
nodes that together with s are involved in the cycle.

It ignores any self loops.
zGraph has no nodes.c                 óf   <€ \        SP                  V ,          P                  4       S,          4      # r/   r7   r:   s   &€€r   r<   Ú*_find_chordality_breaker.<locals>.<lambda>I  s   ø€ ¬#¨a¯f©f°Q­i¯n©nÓ.>ÀÕ.IÔ*Jr   r>   ztreewidth_bound exceeded: éÿÿÿÿr   )r   r   ÚNetworkXPointlessConceptr   r   rC   rD   r!   r0   rF   r   rW   )r   r"   r$   rH   Úcurrent_treewidthr)   rI   rK   r(   r*   r;   s   f&&       @r   r   r   4  s  ù€ ô ˆ1ƒv�„{Ü×)Ò)Ð*?Ó@Ð@Ü�Q“€JØ‚yÜ˜aÓ ˆØ×Ñ�aÔØˆs€HØÐß
ô �
Õ JÔKˆØ×Ñ˜!ÔØ�‰�QŒÜ˜a �d›) hÕ.ˆØ�Z‰Z˜Ó(ˆÜ˜b×!Ò!ä #Ð$5´s¸?Ó7KÓ LÐØ Ô2Ü×7Ò7Ø0Ð1BÐ0CÐDóð ñ 3ô (¨Ó+‰FˆQØ˜!�9ÐØ€Ir   T)Úreturns_graphc           	     ó¢  a€ V P                  4       pV Uu/ uF  q"^ bK  	  pp\        P                  ! V4      '       d   W3# \        4       pVP	                  4        Uu/ uF  q"^ bK  	  upo\        VP	                  4       4      p\        \        VP	                  4       4      ^ R4       EF   p\        VV3R lR7      pVP                  V4       WcV&   . pV F°  p	V P                  W—4      '       d   VP                  V	4       K-  SV	,          p
V Uu. uF  pSV,          V
8  g   K  VNK  	  pp\        P                  ! VP                  W·V	.,           4      W—4      '       g   K�  VP                  V	4       VP                  Wy34       K²  	  V F  pSV;;,          ^,          uu&   K  	  EK  	  VP                  V4       W3# u upi u upi u upi )a‡  Return a copy of G completed to a chordal graph

Adds edges to a copy of G to create a chordal graph. A graph G=(V,E) is
called chordal if for each cycle with length bigger than 3, there exist
two non-adjacent nodes connected by an edge (called a chord).

Parameters
----------
G : NetworkX graph
    Undirected graph

Returns
-------
H : NetworkX graph
    The chordal enhancement of G
alpha : Dictionary
        The elimination ordering of nodes of G

Notes
-----
There are different approaches to calculate the chordal
enhancement of a graph. The algorithm used here is called
MCS-M and gives at least minimal (local) triangulation of graph. Note
that this triangulation is not necessarily a global minimum.

https://en.wikipedia.org/wiki/Chordal_graph

References
----------
.. [1] Berry, Anne & Blair, Jean & Heggernes, Pinar & Peyton, Barry. (2004)
       Maximum Cardinality Search for Computing Minimal Triangulations of
       Graphs.  Algorithmica. 39. 287-298. 10.1007/s00453-004-1084-3.

Examples
--------
>>> from networkx.algorithms.chordal import complete_to_chordal_graph
>>> G = nx.wheel_graph(10)
>>> H, alpha = complete_to_chordal_graph(G)
c                 ó   <€ SV ,          # r/   r   )ÚnodeÚweights   &€r   r<   Ú+complete_to_chordal_graph.<locals>.<lambda>�  s	   ø€ °6¸$¶<r   r>   r[   )r1   r   r   r   r   rT   Úranger   rD   rC   Úhas_edgeÚappendÚhas_pathr0   r!   Úadd_edges_from)r   r%   ra   ÚalphaÚchordsÚunnumbered_nodesÚiÚzÚupdate_nodesÚyÚy_weightÚlower_nodesrb   s   &           @r   Úcomplete_to_chordal_graphrr   ]  s�  ø€ ðT 	
�‰‹€AÙ!"Ó#¡˜�1ŠW¡€EÐ#Ü	‡}‚}�Q×ÒØˆxˆÜ‹U€FØ"#§'¡'¤)Ó,¡)˜$�AŠg¡)Ñ,€FÜ˜AŸG™G›I“ÐÜ”3�q—w‘w“y“> 1 b×)ˆäÐ Ô&?Ô@ˆØ×Ñ Ô"Øˆa‰ØˆÛ!ˆAØ�z‰z˜!×ÒØ×#Ñ# AÖ&ð " !�9�á%5óÙ%5˜T¸À½ÈÑ9P—D�DÑ%5ð ð ô —;’;˜qŸz™z¨+¸A¸Õ*>Ó?À×FÔFØ ×'Ñ'¨Ô*Ø—J‘J ˜vÖ&ñ "ó !ˆDØ�4�L˜AÕ�Lô !ñ' *ð* ×Ñ�VÔØˆ8€Oùò9 $ùò -ùòs   –GÁGÄGÄ&G)r   r,   rL   rN   r   rr   )r   ÚsysÚnetworkxr   Únetworkx.algorithms.componentsr   Únetworkx.utilsr   r   Ú__all__ÚNetworkXExceptionr   Ú_dispatchabler   Úmaxsizer,   rL   rN   rF   rW   r   rr   r   r   r   Ú<module>r{      s  ðñó ã Ý ?ß Aò€ô R×%9Ñ%9ô ñ
 �ZÓ Ù�\Ó"Ø×Ññ81ó ó #ó !ð81ðv ×ÑØ03·±ó Ló ðLð^ ×ÑñG-ó ðG-ðT ×Ññ$>ó ð$>òN	ò&ð #'¸¿¹ô &ñR �ZÓ Ø×Ò Ô%ñEó &ó !òEr   