
    h	                     L    S r SSKrSSKrS/r\R
                  " SSS9S 5       rg)z
Time Series Graphs
    Nvisibility_graphT)graphsreturns_graphc           	        ^^ [         R                  " [        U 5      5      n[         R                  " U[	        [        U 5      5      S5        [        R                  " [        U 5      S5       H[  u  u  p#u  pEXS-
  XB-
  -  mUTU-  -
  m[        UU4S j[        XS-   U US-   S9 5       5      nU(       a  MJ  UR                  X$5        M]     U$ )a  
Return a Visibility Graph of an input Time Series.

A visibility graph converts a time series into a graph. The constructed graph
uses integer nodes to indicate which event in the series the node represents.
Edges are formed as follows: consider a bar plot of the series and view that
as a side view of a landscape with a node at the top of each bar. An edge
means that the nodes can be connected by a straight "line-of-sight" without
being obscured by any bars between the nodes.

The resulting graph inherits several properties of the series in its structure.
Thereby, periodic series convert into regular graphs, random series convert
into random graphs, and fractal series convert into scale-free networks [1]_.

Parameters
----------
series : Sequence[Number]
   A Time Series sequence (iterable and sliceable) of numeric values
   representing times.

Returns
-------
NetworkX Graph
    The Visibility Graph of the input series

Examples
--------
>>> series_list = [range(10), [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]]
>>> for s in series_list:
...     g = nx.visibility_graph(s)
...     print(g)
Graph with 10 nodes and 9 edges
Graph with 12 nodes and 18 edges

References
----------
.. [1] Lacasa, Lucas, Bartolo Luque, Fernando Ballesteros, Jordi Luque, and Juan Carlos Nuno.
       "From time series to complex networks: The visibility graph." Proceedings of the
       National Academy of Sciences 105, no. 13 (2008): 4972-4975.
       https://www.pnas.org/doi/10.1073/pnas.0709247105
value   c              3   >   >#    U  H  u  pUTU-  T-   :  v   M     g 7f)N ).0ntoffsetslopes      Q/var/www/html/env/lib/python3.13/site-packages/networkx/generators/time_series.py	<genexpr>#visibility_graph.<locals>.<genexpr>B   s(      
D V##Ds      )start)
nx
path_graphlenset_node_attributesdict	enumerate	itertoolscombinationsanyadd_edge)	seriesGn1t1n2t2
obstructedr   r   s	          @@r   r   r      s    Z 	c&k"A1d9V#45w? (44Yv5FJ(2RW%ebj 
!&a""5R!VD
 


 zJJr K H    )__doc__r   networkxr   __all___dispatchabler   r
   r&   r   <module>r+      s;     
 T2= 3=r&   