ó
    …~i½  ã                   óR   • S r SSKJr  SSKrSrSrS/r\R                  SS j5       r	g)	z›
=============================
Breadth First Search on Edges
=============================

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

é    )ÚdequeNÚforwardÚreverseÚedge_bfsc           	   #   óz  ^ ^^#   • [        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  T R                  nU4S jnOT R                  nS nU=(       a    TS;   n[        U5      n	[        5       n
[        U Vs/ s H  o»U" U5      4PM     sn5      nU(       a™  UR                  5       u  pÞU Hw  nU(       a  US   [        :X  a  US   nOUS   nUU	;  a*  U	R                  U5        UR                  UU" U5      45        U" U5      nUU
;  d  Mb  U
R                  U5        Uv •  My     U(       a  M˜  ggs  snf 7f)ad  A directed, breadth-first-search of edges in `G`, beginning at `source`.

Yield the edges of G in a breadth-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 breadth-first-search.
    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
--------
>>> from pprint import pprint
>>> nodes = [0, 1, 2, 3]
>>> edges = [(0, 1), (1, 0), (1, 0), (2, 0), (2, 1), (3, 1)]

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

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

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

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

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

>>> elist = list(nx.edge_bfs(nx.MultiDiGraph(edges), nodes, orientation="ignore"))
>>> pprint(elist)
[(0, 1, 0, 'forward'),
 (1, 0, 0, 'reverse'),
 (1, 0, 1, 'reverse'),
 (2, 0, 0, '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 breadth-first-search of nodes, as provided by
:func:`networkx.algorithms.traversal.breadth_first_search.bfs_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.

The naming of this function is very similar to bfs_edges. The difference
is that 'edge_bfs' yields edges even if they extend back to an already
explored node while 'bfs_edges' yields the edges of the tree that results
from a breadth-first-search (BFS) so no edges are reported if they extend
to already explored nodes. That means 'edge_bfs' reports all edges while
'bfs_edges' only report those traversed by a node-based BFS. Yet another
description is that 'bfs_edges' reports the edges traversed during BFS
while 'edge_bfs' reports all edges in the order they are explored.

See Also
--------
bfs_edges
bfs_tree
edge_dfs

NÚdataFTÚkeysc                 ó<   >• [        TR                  " U 40 TD65      $ ©N)ÚiterÚedges)ÚnodeÚGÚkwdss    €€Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/traversal/edgebfs.pyÚ
edges_fromÚedge_bfs.<locals>.edges_from   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   „   s*   øé € Ø—W’W˜TÑ* 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   Š   s*   øé € Ø—Z’Z Ñ-¨Ô-�Øœ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   øé € Ø—W’W˜TÑ* TÔ*�Øœ7˜*‘nÔ$ñ +à—Z’Z Ñ-¨Ô-�Øœ7˜*‘nÔ$ò .ùs   ƒAAzinvalid orientation argument.c                 ó   >• Tb  U S S $ U $ )Néÿÿÿÿ© )ÚedgeÚorientations    €r   Úedge_idÚedge_bfs.<locals>.edge_idœ   s   ø€ à +Ñ 7�4˜˜�9ÐA¸TÐAr   c                 ó,   • [        U S S 5      4U SS  -   $ )Né   )Ú	frozenset)r#   s    r   r%   r&   £   s!   € Ü˜d 2 A˜hÓ'Ð)¨D°°¨HÑ4Ð4r   )r   r   r!   r   é   )ÚlistÚnbunch_iterÚis_directedÚis_multigraphÚnxÚNetworkXErrorÚ
successorsÚ	neighborsÚsetr   Úpopleftr   ÚaddÚappend)r   Úsourcer$   ÚnodesÚdirectedr   r2   r%   Úcheck_reverseÚvisited_nodesÚvisited_edgesÚnÚqueueÚparentÚchildren_edgesr#   ÚchildÚedgeidr   s   ` `               @r   r   r      s›  úé € ô~ �—‘˜vÓ&Ó'€EÞØà�}‰}‹€HØ�Eˆ?€DØ‡�Ó˜DÒ ØˆˆV‰ð Ñ÷	/ö ˜¨
Ó2÷	%ð 
˜	Ó	!÷	%ð 
˜Ó	 ÷	%ô ×ÒÐ>Ó?Ð?æØ—L‘Lˆ	ö	Bð
 —K‘Kˆ	ò	5ð ×E Ð0EÑ!E€Mô ˜“J€MÜ“E€MÜ©uÓ5ªu¨!‘z !“}Ó%©uÑ5Ó6€EÞ
Ø!&§¡£ÑˆÛ"ˆDÞ  b¡¬WÓ!4Ø˜Q™‘à˜Q™�Ø˜MÓ)Ø×!Ñ! %Ô(Ø—‘˜e¡Z°Ó%6Ð7Ô8Ù˜T“]ˆFØ˜]Õ*Ø×!Ñ! &Ô)Ø”
ñ #÷ Š%ùò 6ùs   …C6F;Ã;F6ÄB F;Æ F;Æ4F;)NN)
Ú__doc__Úcollectionsr   Únetworkxr/   r   r   Ú__all__Ú_dispatchabler   r"   r   r   Ú<module>rH      s?   ðñõ ã à
€Ø
€àˆ,€ð ×Ñódó ñdr   