From 781a40d17a568fedf2b943f7416ea9637716ef84 Mon Sep 17 00:00:00 2001 From: azizkayumov Date: Sun, 12 Nov 2023 04:36:59 +0900 Subject: [PATCH] fix tests --- src/lctree.rs | 9 ++++++--- src/lib.rs | 9 +++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lctree.rs b/src/lctree.rs index 4ee3c92..f1b18e2 100644 --- a/src/lctree.rs +++ b/src/lctree.rs @@ -186,8 +186,11 @@ impl LinkCutTree

{ /// assert!(!lctree.linked(alice, clay)); // alice and clay are not connected by a link /// ``` pub fn linked(&mut self, v: usize, w: usize) -> bool { - self.connected(v, w); - self.forest.left_of(w) == Some(v) && self.forest.right_of(v).is_none() + if self.connected(v, w) { + self.forest.left_of(w) == Some(v) && self.forest.right_of(v).is_none() + } else { + false + } } /// Merges two trees into a single tree. @@ -206,7 +209,7 @@ impl LinkCutTree

{ /// assert!(lctree.connected(alice, clay)); /// ``` pub fn link(&mut self, v: usize, w: usize) -> bool { - if !self.connected(v, w) { + if self.connected(v, w) { return false; } // v is the root of its represented tree: diff --git a/src/lib.rs b/src/lib.rs index d6881e3..31b2646 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,12 +9,9 @@ //! This crate implements link-cut tree for unrooted trees, which means all of the above operations //! can be performed on any two nodes in the forest. //! -//! # Path aggregation -//! Common path aggregates are provided as follows: -//! - `findmax(v, w)`: returns the maximum value on a path between nodes `v` and `w`. -//! - `findmin(v, w)`: returns the minimum value on a path between nodes `v` and `w`. -//! - `findsum(v, w)`: returns the sum of values on a path between nodes `v` and `w`. -//! A custom aggregation function can also be implemented by using the [Path] trait. +//! # Path operations +//! The most common path aggregates are supported: `FindMax`, `FindMin`, and `FindSum`. +//! A custom path aggregate function can be implemented by using the [Path] trait. //! //! # Tree creation and removal //! Tree nodes are created and removed using the following operations: