Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azizkayumov committed Nov 11, 2023
1 parent 109686a commit 781a40d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/lctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ impl<P: Path> LinkCutTree<P> {
/// 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.
Expand All @@ -206,7 +209,7 @@ impl<P: Path> LinkCutTree<P> {
/// 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:
Expand Down
9 changes: 3 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 781a40d

Please sign in to comment.