%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/samba/kcc/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/samba/kcc/__pycache__/graph_utils.cpython-312.pyc

�

�I�d-0���ddlZddlZddlmZ		dd�ZGd�de�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zdd�Z						dd�Zd�Zy)�N)�	dot_graphc��t||fd|i|��}|r|d|jdd�zz
}tjj	|d|z�}|�|d|z�t|d�}	|	j
|�|	j�y)N�title�_�, �z%s.dotzwriting graph to %s�w)r�replace�os�path�join�open�write�close)
�basename�	edge_list�vertices�label�dot_file_dir�debug�kwargs�s�filename�fs
          �7/usr/lib/python3/dist-packages/samba/kcc/graph_utils.py�write_dot_filers����(�I�=�U�=�f�=�A���C�%�-�-��b�1�1�1���w�w�|�|�L�(�X�*=�>�H���
�#�h�.�/��X�s��A��G�G�A�J��G�G�I�c��eZdZy)�
GraphErrorN)�__name__�
__module__�__qualname__�rrrr*s��rrc���|D]i}t�}|D]3\}}||k(r|j|��||k(s�#|j|��5t|�dzt|�k7s�`td��y)zXThe graph is complete, which is to say there is an edge between
    every pair of nodes.�zgraph is not fully connectedN)�set�add�lenr)�edgesr�
edge_vertices�v�remotes�a�bs       r�verify_graph_completer/.st���=���%���	�D�A�q��A�v����A���a�����A��		�
�w�<�!��s�8�}�,��;�<�<�=rc��
�|st|�dkrytd��t|�}t|j	���
	g}t|�D]X\}}|\}}|�
vr#�
j
|�|j|��2|�
vs�7�
j
|�|j|��Z|snt|�D]}||=��|s�
t|�k7r3d}	|	dj�
fd�t|�D��z
}	t|	��y)z&There is a path between any two nodes.r%Nz9all vertices are disconnected because there are no edges:zHthe graph is not connected, as the following vertices are unreachable:
 z
 c3�*�K�|]
}|�vr|���y�w�Nr#)�.0r+�reacheds  �r�	<genexpr>z)verify_graph_connected.<locals>.<genexpr>Xs �����-�a��G�+��-�s�)r(r�listr&�pop�	enumerater'�append�reversedr
�sorted)r)rr*�remaining_edges�doomed�i�er-r.rr4s          @r�verify_graph_connectedr@<s�����x�=�A����/�0�	0��5�k�O��/�%�%�'�(�G�
����o�.�	!�D�A�q��D�A�q��G�|����A���
�
�a� ��g�����A���
�
�a� �	!����&�!�	#�A���"�	#���'�S��]�2�=��	�U�Z�Z�-�6�(�#3�-�-�	-����m��3rc��t|�dk(r
t|||�Stj|t|�dz
�D]}	t|||��y#t$r#}|D]}||vs�t	d|z��Yd}~�;d}~wwxYw)z:The graph stays connected when any single edge is removed.rr%zFThe graph will be disconnected when the connection from %s to %s failsN)r(r@�	itertools�combinationsr)r)rr*�subsetr?�edges      r�*verify_graph_connected_under_edge_failuresrF]s���
�5�z�Q��%�e�X�}�E�E��(�(���E�
�Q��?�N��	N�"�6�8�]�C�N���	N��
N���v�%�$�&F�HL�&M�N�N�
N��	N�s�
A�	A>�	A9�%A9�9A>c��|D]7}|D�cgc]	}||us�|��}}|D�cgc]	}||vs�|��}}t|||��9ycc}wcc}w)z<The graph stays connected when any single vertex is removed.N)r@)r)rr*r+�x�sub_vertices�	sub_edgess       r�,verify_graph_connected_under_vertex_failuresrKlsY���F��#+�:�a�q��z��:��:� %�4�1��!��Q�4�	�4��y�,��E�F��:��4s�	>�>�	A�Ac	��|D�cgc]
}t|���}}	tj|d�D]F\}}||z}|s�t|�dk(r||z}|j	|�ntd|�d|�d|����y�acc}w)zThe graph contains no loops.�r%z'there is a loop in the graph
 vertices z
 edges z
 intersection N�r&rBrCr(�remover)r)rr*r?�treesr-r.�intersections        r�verify_graph_forestrRus���"�#��S��V�#�E�#�
��*�*�5�!�4�	�D�A�q��q�5�L���|�$��)���F�A��L�L��O��$�'/��|�&E�F�F�	�&
�)��
$s�A;c��t|�}|D�cgc]
}t|���}}	tj|d�D]=\}}||z}|s�t|�dk(r||z}|j	|�n
td��y�Xcc}w)a,This allows a forest with duplicate edges. That is if multiple
    edges go between the same two vertices, they are treated as a
    single edge by this test.

    e.g.:
                        o
    pass: o-o=o  o=o   (|)             fail:  o-o
            `o          o                     `o'
    rMr%zthere is a loop in the graphNrN)	r)rr*�unique_edgesr?rPr-r.rQs	         r�verify_graph_multi_edge_forestrU�s����u�:�L�)�*��S��V�*�E�*�
��*�*�5�!�4�
	�D�A�q��q�5�L���|�$��)���F�A��L�L��O��$�%C�D�D�
	�
���
+s�A=c��t|�t|�z
}|r&tddjt|��z��y)z$There are no vertices without edges.z#some vertices are not connected:
%s�
N�r&rr
r;)r)rr*�lonelys    r�verify_graph_no_lonely_verticesrZ�sB��
��]�S��/�
/�F�
��?����6�&�>�2�3�4�	4�rc��t|�t|�z
}|r&tddjt|��z��y)zBThe edge endpoints contain no vertices that are otherwise unknown.z,some edge vertices are seemingly unknown:
%srWNrX)r)rr*�unknowns    r� verify_graph_no_unknown_verticesr]�sB���-� �3�x�=�0�G���H����6�'�?�3�4�5�	5�rc����|st|�dkryt|�dt|�zkrtd��t|�}t�}|D]I}|d|df}||vs�||vs�|j|�|j	|�|j	|��Ki}|D]W\}}	|j|t��j|	�|j|	t��j|��Y|j
�D]!\}
}t|�dk(s�td|
z��t|j��D]D}
||
}|s�|D]2�|�}
|
j	|
�|
j�fd�|D���4||
=�Ft|�dkDr+tdd	j|j��z��t|||�t|||�y)
a7Each node has at least two directed edges leaving it, and two
    arriving. The edges work in pairs that have the same end points
    but point in opposite directions. The pairs form a path that
    touches every vertex and form a loop.

    There might be other connections that *aren't* part of the ring.

    Deciding this for sure is NP-complete (the Hamiltonian path
    problem), but there are some easy failures that can be detected.
    So far we check for:
      - leaf nodes
      - disjoint subgraphs
      - robustness against edge and vertex failure
    r%NrMzFdirected double ring requires at least twice as many edges as verticesrz2wanted double directed ring, found a leaf node(%s)c3�.�K�|]}|�k7s�	|���y�wr2r#)r3rH�ns  �rr5z4verify_graph_directed_double_ring.<locals>.<genexpr>�s�����:�a�1��6��:�s�
�zZwanted double directed ring, but this looks like a split graph
(%s can't reach each other)r)
r(rr&r'rO�
setdefault�itemsr6�keys�updater
rFrK)r)rr*�half_duplex�duplex_linksrE�rev_edge�edge_mapr-r.�vertex�
neighbours�nset�n_neighboursr`s              @r�!verify_graph_directed_double_ringrm�s
���$�S��]�a�'��
�5�z�A��H�
�%�%��5�6�	6��e�*�K��5�L��)����G�T�!�W�%���;��8�{�#:����T�"����t�$����x�(�)�(�H��-���1����A�s�u�%�)�)�!�,����A�s�u�%�)�)�!�,�-�
'�n�n�.�.���
��z�?�a���$�&,�-�.�
.�.�
�x�}�}��'����������	;�A�#�A�;�L�����'����:�4�:�:�	;�
�V����8�}�q���7����8�=�=�?�3�4�5�	5�
/�|�X�/<�>�0��x�1>�@rc���t|�dkryt|�dk(r=	t|�dk(r#|dd|ddk(r|dd|ddk(rytd��t|||�S)z�This performs the directed_double_ring test but makes special
    concessions for small rings where the strict rules don't really
    apply.rMNrr%z0A two vertex graph should have an edge each way.)r(rrm)r)rr*s   r�*verify_graph_directed_double_ring_or_smallro	s{���8�}�q���
�8�}���L���J�!�O��!�H�Q�K�5��8�A�;�&��!�H�Q�K�5��8�A�;�&���K�L�L�,�U�H�m�L�Lrc��g}|D�cgc]}|jdd���}}t�}|D]'\}}|j|�|j|��)|�|}nt|�}|D]}	d|	z}
t�|
}	||||��!|Scc}w#t$r(}|j|	||jf�Yd}~�Ud}~wwxYw)N� rzverify_graph_%s)r
r&r'�globalsrr9�__doc__)
r)r�directed�
properties�errorsrHr*r-r.�p�fnrr?s
             r�verify_graphrys���
�F�/9�:�!�!�)�)�C��%�:�J�:��E�M�����1����!�����!����� ���x�=��
�-��
��
"���I�b�M��	-�
�e�X�}�-�	-��M��);��"�	-��M�M�1�a����+�,�,��	-�s�B�
B�	C�B?�?Cc
��|
�t|||||
||||||
��|	rkt|||��}|rZ|�d|xsd��}|d|z�|D]\}}}|d|d�d|����|r'td|�d	d
jd�|D������yyy)N)	rrr�reformat_labelsrtr�edge_colors�edge_labels�
vertex_colors)rurqrz
%s FAILED:z>18�: zThe 'z(' graph lacks the following properties:
rWc3�2K�|]\}}}|�d|�����y�w)rNr#)r3rwr?�docs    rr5z!verify_and_dot.<locals>.<genexpr>Ls'����3L�7@�q�!�S�@A�!�3D�3L�s�)rryrr
)rr)rrr{rtru�fatalr�verifyrr|r}r~rvrrwr?r�s                   r�verify_and_dotr�3s������x����$0�'6��"��#.�m�		M���e�X�)3�5���'���"��5�E��,��&�'�#�
,�	��1�c��Q��*�+�
,�� �"'����3L�DJ�3L�*L�"M�N�N���rc�*�tt�j��D]o\}}|jd�s�t	|jdd��|jr't	d|jj�z��ft	��qy)N�
verify_graph_rz    %s)r;rrrb�
startswith�printr
rs�rstrip)�kr+s  r�list_verify_testsr�Psh���w�y���(�)����1��<�<��(��!�)�)�O�R�0�1��y�y��h�!�)�)�"2�"2�"4�5�6���
r)NNNN)NFr#)NNTFr#TNTNNNN)rrB�samba.graphrr�	Exceptionrr/r@rFrKrRrUrZr]rmroryr�r�r#rr�<module>r�s���*
��!�>B�,0��	��	�=��BN�F��4�44�5�M@�`M�"�2:>�27�48�-1�15�!%�N�:r

Zerion Mini Shell 1.0