
    hE                     F    S r SSKrSrSrS/r\R                  SS j5       rg)z
===========================
Depth First Search on Edges
===========================

Algorithms for a depth-first traversal of edges in a graph.

    Nforwardreverseedge_dfsc              #   \  ^ ^^#    [        T R                  U5      5      nU(       d  gT R                  5       nSS0mT R                  5       SL a  STS'   Tc  U U4S jnOGU(       a  TS:X  a  U U4S jnO2TS	:X  a  U U4S
 jnO$TS:X  a  U U4S jnO[        R
                  " S5      eU(       a  U4S jnOS nU=(       a    TS;   n[        5       n[        5       n	0 n
U H  nU/nU(       d  M  US   nX;  a  U" U5      X'   U	R                  U5         [        X   5      nU" U5      nX;  aR  UR                  U5        U(       a"  US   [        :X  a  UR                  US   5        OUR                  US   5        Uv   U(       a  M  M     g! [         a    UR                  5          N*f = f7f)a  A directed, depth-first-search of edges in `G`, beginning at `source`.

Yield the edges of G in a depth-first-search order continuing until
all edges are generated.

Parameters
----------
G : graph
    A directed/undirected graph/multigraph.

source : node, list of nodes
    The node from which the traversal begins. If None, then a source
    is chosen arbitrarily and repeatedly until all edges from each node in
    the graph are searched.

orientation : None | 'original' | 'reverse' | 'ignore' (default: None)
    For directed graphs and directed multigraphs, edge traversals need not
    respect the original orientation of the edges.
    When set to 'reverse' every edge is traversed in the reverse direction.
    When set to 'ignore', every edge is treated as undirected.
    When set to 'original', every edge is treated as directed.
    In all three cases, the yielded edge tuples add a last entry to
    indicate the direction in which that edge was traversed.
    If orientation is None, the yielded edge has no direction indicated.
    The direction is respected, but not reported.

Yields
------
edge : directed edge
    A directed edge indicating the path taken by the depth-first traversal.
    For graphs, `edge` is of the form `(u, v)` where `u` and `v`
    are the tail and head of the edge as determined by the traversal.
    For multigraphs, `edge` is of the form `(u, v, key)`, where `key` is
    the key of the edge. When the graph is directed, then `u` and `v`
    are always in the order of the actual directed edge.
    If orientation is not None then the edge tuple is extended to include
    the direction of traversal ('forward' or 'reverse') on that edge.

Examples
--------
>>> nodes = [0, 1, 2, 3]
>>> edges = [(0, 1), (1, 0), (1, 0), (2, 1), (3, 1)]

>>> list(nx.edge_dfs(nx.Graph(edges), nodes))
[(0, 1), (1, 2), (1, 3)]

>>> list(nx.edge_dfs(nx.DiGraph(edges), nodes))
[(0, 1), (1, 0), (2, 1), (3, 1)]

>>> list(nx.edge_dfs(nx.MultiGraph(edges), nodes))
[(0, 1, 0), (1, 0, 1), (0, 1, 2), (1, 2, 0), (1, 3, 0)]

>>> list(nx.edge_dfs(nx.MultiDiGraph(edges), nodes))
[(0, 1, 0), (1, 0, 0), (1, 0, 1), (2, 1, 0), (3, 1, 0)]

>>> list(nx.edge_dfs(nx.DiGraph(edges), nodes, orientation="ignore"))
[(0, 1, 'forward'), (1, 0, 'forward'), (2, 1, 'reverse'), (3, 1, 'reverse')]

>>> list(nx.edge_dfs(nx.MultiDiGraph(edges), nodes, orientation="ignore"))
[(0, 1, 0, 'forward'), (1, 0, 0, 'forward'), (1, 0, 1, 'reverse'), (2, 1, 0, 'reverse'), (3, 1, 0, 'reverse')]

Notes
-----
The goal of this function is to visit edges. It differs from the more
familiar depth-first traversal of nodes, as provided by
:func:`~networkx.algorithms.traversal.depth_first_search.dfs_edges`, in
that it does not stop once every node has been visited. In a directed graph
with edges [(0, 1), (1, 2), (2, 1)], the edge (2, 1) would not be visited
if not for the functionality provided by this function.

See Also
--------
:func:`~networkx.algorithms.traversal.depth_first_search.dfs_edges`

NdataFTkeysc                 <   > [        TR                  " U 40 TD65      $ N)iteredges)nodeGkwdss    W/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/traversal/edgedfs.py
edges_fromedge_dfs.<locals>.edges_fromk   s    --..    originalc              3   Z   >#    TR                   " U 40 TD6 H  nU[        4-   v   M     g 7fr
   )r   FORWARDr   er   r   s     r   r   r   p   s*     WWT*T*7*n$ +   (+r   c              3   Z   >#    TR                   " U 40 TD6 H  nU[        4-   v   M     g 7fr
   )in_edgesREVERSEr   s     r   r   r   v   s*     ZZ--7*n$ .r   ignorec              3      >#    TR                   " U 40 TD6 H  nU[        4-   v   M     TR                  " U 40 TD6 H  nU[        4-   v   M     g 7fr
   )r   r   r   r   r   s     r   r   r   |   sN     WWT*T*7*n$ +ZZ--7*n$ .s   AAzinvalid orientation argument.c                    > Tb  U S S $ U $ )N )edgeorientations    r   edge_idedge_dfs.<locals>.edge_id   s     + 749ATAr   c                 ,    [        U S S 5      4U SS  -   $ )N   )	frozenset)r"   s    r   r$   r%      s!    d2Ah')DH44r   )r   r   r    r      )listnbunch_iteris_directedis_multigraphnxNetworkXErrorsetaddnextr   appendStopIterationpop)r   sourcer#   nodesdirectedr   r$   check_reversevisited_edgesvisited_nodesr   
start_nodestackcurrent_noder"   edgeidr   s   ` `             @r   r   r      s    Z v&'E}}HE?DD V 	/ 
2	% 
		!	% 
	 	% >?? 	B	5
 E0E!EMEMEME 
e 9L0&0&>#!!,/E/0
 !.!%%f-$bW)<T!W-T!W-J) e  ! 		s7   C#F,,%F,FA&F,F,F)&F,(F))F,)NN)__doc__networkxr.   r   r   __all___dispatchabler   r!   r   r   <module>rD      s<    

, ] ]r   