a
HlX`
@s4dZddlZddlZddgZdddZd ddZdS)
zT
Provides functions for finding and testing for locally `(k, l)`connected
graphs.
Nkl_connected_subgraphis_kl_connectedFc Cs@t}d}d}r.d}tD]}\} }
r 
h}tD] }D]}

qVqJ}n
t} 
g}d}d}r
d7}krd}q
 }D]}

kr

}qzt  
}Wqtj
yd}Yq0qdkr( 
d}r(d}q(qr<fSS)aPReturns the maximum locally `(k, l)`connected subgraph of `G`.
A graph is locally `(k, l)`connected if for each edge `(u, v)` in the
graph there are at least `l` edgedisjoint paths of length at most `k`
joining `u` to `v`.
Parameters

G : NetworkX graph
The graph in which to find a maximum locally `(k, l)`connected
subgraph.
k : integer
The maximum length of paths to consider. A higher number means a looser
connectivity requirement.
l : integer
The number of edgedisjoint paths. A higher number means a stricter
connectivity requirement.
low_memory : bool
If this is True, this function uses an algorithm that uses slightly
more time but less memory.
same_as_graph : bool
If True then return a tuple of the form `(H, is_same)`,
where `H` is the maximum locally `(k, l)`connected subgraph and
`is_same` is a Boolean representing whether `G` is locally `(k,
l)`connected (and hence, whether `H` is simply a copy of the input
graph `G`).
Returns

NetworkX graph or twotuple
If `same_as_graph` is True, then this function returns a
twotuple as described above. Otherwise, it returns only the maximum
locally `(k, l)`connected subgraph.
See also

is_kl_connected
References

.. [1]: Chung, Fan and Linyuan Lu. "The Small World Phenomenon in Hybrid
Power Law Graphs." *Complex Networks*. Springer Berlin Heidelberg,
2004. 89104.
TFr)copydeepcopylistedgesrangeupdatesubgraphremove_edgenx
shortest_pathNetworkXNoPath)Gkl
low_memoryZ
same_as_graphHgraphOKZdeleted_someedgeuvvertsiwG2pathcntacceptprevr!/Users/cmdms/OneDriveUOB/Development/Projects/2021/samconsensusv3/env/lib/python3.9/sitepackages/networkx/algorithms/hybrid.pyrsN2
c sd}D]}\}}rVhtD]}fddDq,} n
t} g}
d}d}
rd7}krd}q}

D]}
kr 
}
qzt }
Wqptjyd}
Yqp0qpdkrd}qqS)a\Returns True if and only if `G` is locally `(k, l)`connected.
A graph is locally `(k, l)`connected if for each edge `(u, v)` in the
graph there are at least `l` edgedisjoint paths of length at most `k`
joining `u` to `v`.
Parameters

G : NetworkX graph
The graph to test for local `(k, l)`connectedness.
k : integer
The maximum length of paths to consider. A higher number means a looser
connectivity requirement.
l : integer
The number of edgedisjoint paths. A higher number means a stricter
connectivity requirement.
low_memory : bool
If this is True, this function uses an algorithm that uses slightly
more time but less memory.
Returns

bool
Whether the graph is locally `(k, l)`connected subgraph.
See also

kl_connected_subgraph
References

.. [1]: Chung, Fan and Linyuan Lu. "The Small World Phenomenon in Hybrid
Power Law Graphs." *Complex Networks*. Springer Berlin Heidelberg,
2004. 89104.
Tcsg]}qSr!)r
Z neighbors).0rrrr!r"
z#is_kl_connected..rrF) rr rrrrr
rr)rrrrrrrrrrrrrr rr!r$r"rts<(
)FF)F)__doc__rZnetworkxr
__all__rrr!r!r!r"s
h