summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLonnen <lonnen@users.noreply.github.com>2021-02-15 05:52:29 -0800
committerGitHub <noreply@github.com>2021-02-15 08:52:29 -0500
commite2c28cd2dd9363d869f731284a0dabf4fd44fe94 (patch)
tree0a0569815f0e9f7ce7b5456f4613267974295a8c
parent37f63fb7d95617493184a4c2444b69da867fb715 (diff)
downloadnetworkx-e2c28cd2dd9363d869f731284a0dabf4fd44fe94.tar.gz
return earlier from `clique.graph_clique_number` (#4622)
Fixes bug #4621 by moving an early return opportunity earlier into the method call, potentially avoiding one function call to `find_cliques` that otherwise returns early, itself
-rw-r--r--networkx/algorithms/clique.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/networkx/algorithms/clique.py b/networkx/algorithms/clique.py
index 09413146..803507b8 100644
--- a/networkx/algorithms/clique.py
+++ b/networkx/algorithms/clique.py
@@ -420,10 +420,10 @@ def graph_clique_number(G, cliques=None):
maximal cliques.
"""
- if cliques is None:
- cliques = find_cliques(G)
if len(G.nodes) < 1:
return 0
+ if cliques is None:
+ cliques = find_cliques(G)
return max([len(c) for c in cliques] or [1])