
    \Mh                     Z    d Z ddlmZ ddlZdgZ ej        dd          d             ZdS )z 
Generators for interval graph.
    )SequenceNinterval_graphT)graphsreturns_graphc                    t          |           } | D ]]}t          |t                    rt          |          dk    st	          d          |d         |d         k    rt          d|           ^t          j                    }d | D             }|                    |           |rG|	                                x\  }}}|D ])}|\  }}	||k    r|	|k    r|
                    ||           *|G|S )ao  Generates an interval graph for a list of intervals given.

    In graph theory, an interval graph is an undirected graph formed from a set
    of closed intervals on the real line, with a vertex for each interval
    and an edge between vertices whose intervals intersect.
    It is the intersection graph of the intervals.

    More information can be found at:
    https://en.wikipedia.org/wiki/Interval_graph

    Parameters
    ----------
    intervals : a sequence of intervals, say (l, r) where l is the left end,
    and r is the right end of the closed interval.

    Returns
    -------
    G : networkx graph

    Examples
    --------
    >>> intervals = [(-2, 3), [1, 4], (2, 3), (4, 6)]
    >>> G = nx.interval_graph(intervals)
    >>> sorted(G.edges)
    [((-2, 3), (1, 4)), ((-2, 3), (2, 3)), ((1, 4), (2, 3)), ((1, 4), (4, 6))]

    Raises
    ------
    :exc:`TypeError`
        if `intervals` contains None or an element which is not
        collections.abc.Sequence or not a length of 2.
    :exc:`ValueError`
        if `intervals` contains an interval such that min1 > max1
        where min1,max1 = interval
       zZEach interval must have length 2, and be a collections.abc.Sequence such as tuple or list.r      z*Interval must have lower value first. Got c                 ,    g | ]}t          |          S  )tuple).0intervals     b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/generators/interval_graph.py
<listcomp>z"interval_graph.<locals>.<listcomp>=   s    BBBHhBBB    )list
isinstancer   len	TypeError
ValueErrornxGraphadd_nodes_frompopadd_edge)
	intervalsr   graphtupled_intervalsmin1max1	interval1	interval2min2max2s
             r   r   r      s3   J YI V V8X.. 	3x==A3E3EB   A;!$$T(TTUUU % HJJEBB	BBB	)***
 5!1!5!5!7!77
dY) 	5 	5I"JD$t||y)444  5 Lr   )__doc__collections.abcr   networkxr   __all___dispatchabler   r   r   r   <module>r*      so     % $ $ $ $ $    
 T2229 9 329 9 9r   