From 6c61c5ef2b4db48bd5039dbff09aa28d24178152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Wed, 13 Nov 2024 11:41:50 +0000 Subject: [PATCH] feat: Fastpath for `is_node_convex` on a single node --- src/algorithms/convex.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/convex.rs b/src/algorithms/convex.rs index 6e3098a..5337b6f 100644 --- a/src/algorithms/convex.rs +++ b/src/algorithms/convex.rs @@ -80,7 +80,7 @@ where /// Whether the subgraph induced by the node set is convex. /// /// An induced subgraph is convex if there is no node that is both in the - /// past and in the future of another node of the subgraph. + /// past and in the future of some nodes in the subgraph. /// /// This function requires mutable access to `self` because it uses a /// temporary data structure within the object. @@ -103,7 +103,7 @@ where pub fn is_node_convex(&self, nodes: impl IntoIterator) -> bool { // The nodes in the subgraph, in topological order. let nodes: BTreeSet<_> = nodes.into_iter().map(|n| self.topsort_ind[n]).collect(); - if nodes.is_empty() { + if nodes.len() <= 1 { return true; }