summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@users.noreply.github.com>2022-06-21 14:02:30 +0200
committerJarrod Millman <jarrod.millman@gmail.com>2022-07-18 11:36:27 -0700
commitbb13c7c4bc6566393f3ceb6115250ec9e294ffa5 (patch)
treedae3265fd19c94fb9acd20de5d0a0500238e09c1
parent6d68954e5dd68d545cd0c4de7b5fb1fcf65a54aa (diff)
downloadnetworkx-bb13c7c4bc6566393f3ceb6115250ec9e294ffa5.tar.gz
Compute `is_weakly_connected` lazily (#5795)
-rw-r--r--networkx/algorithms/components/weakly_connected.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/networkx/algorithms/components/weakly_connected.py b/networkx/algorithms/components/weakly_connected.py
index 4571b101..822719a5 100644
--- a/networkx/algorithms/components/weakly_connected.py
+++ b/networkx/algorithms/components/weakly_connected.py
@@ -157,7 +157,7 @@ def is_weakly_connected(G):
"""Connectivity is undefined for the null graph."""
)
- return len(list(weakly_connected_components(G))[0]) == len(G)
+ return len(next(weakly_connected_components(G))) == len(G)
def _plain_bfs(G, source):