+
    )i	                     <    R t ^ RItR.t]P                  R 4       tR# )z(Function for computing walks in a graph.Nnumber_of_walksc                   ^ RI pV^ 8  d   \        RV 24      h\        P                  ! V RR7      pVP                  P
                  P                  W14      P                  4       p\        V 4       UUUUu/ uF;  w  rVT\        V 4       UUu/ uF  w  rxWWW3,          P                  4       bK  	  uppbK=  	  p	ppppV	# u uppi u uppppi )a7  Returns the number of walks connecting each pair of nodes in `G`

A *walk* is a sequence of nodes in which each adjacent pair of nodes
in the sequence is adjacent in the graph. A walk can repeat the same
edge and go in the opposite direction just as people can walk on a
set of paths, but standing still is not counted as part of the walk.

This function only counts the walks with `walk_length` edges. Note that
the number of nodes in the walk sequence is one more than `walk_length`.
The number of walks can grow very quickly on a larger graph
and with a larger walk length.

Parameters
----------
G : NetworkX graph

walk_length : int
    A nonnegative integer representing the length of a walk.

Returns
-------
dict
    A dictionary of dictionaries in which outer keys are source
    nodes, inner keys are target nodes, and inner values are the
    number of walks of length `walk_length` connecting those nodes.

Raises
------
ValueError
    If `walk_length` is negative

Examples
--------

>>> G = nx.Graph([(0, 1), (1, 2)])
>>> walks = nx.number_of_walks(G, 2)
>>> walks
{0: {0: 1, 1: 0, 2: 1}, 1: {0: 0, 1: 2, 2: 0}, 2: {0: 1, 1: 0, 2: 1}}
>>> total_walks = sum(sum(tgts.values()) for _, tgts in walks.items())

You can also get the number of walks from a specific source node using the
returned dictionary. For example, number of walks of length 1 from node 0
can be found as follows:

>>> walks = nx.number_of_walks(G, 1)
>>> walks[0]
{0: 0, 1: 1, 2: 0}
>>> sum(walks[0].values())  # walks from 0 of length 1
1

Similarly, a target node can also be specified:

>>> walks[0][1]
1

Nz"`walk_length` cannot be negative: )weight)
scipy
ValueErrornxadjacency_matrixsparselinalgmatrix_powertocsr	enumerateitem)
Gwalk_lengthspApoweru_idxuv_idxvresults
   &&        W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/algorithms/walks.pyr   r      s    t Q=k]KLL
Ad+AII))!9??AE "!$HE 	
)A,G,heAU\"'')),GG$   M Hs   5C
#B=.C
=C
)__doc__networkxr   __all___dispatchabler        r   <module>r       s/    . 
 D Dr   