Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sriram98v committed Oct 28, 2024
1 parent b9151de commit 47aee59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ impl ContractTree for SimpleRootedTree {
node_postord_iter.for_each(|orig_node| {
let mut node = orig_node.clone();
match node.is_leaf() {
true => if leaf_ids.contains(&node.get_id()) {
node_map[node.get_id()] = Some(node.clone());
},
true => {
if leaf_ids.contains(&node.get_id()) {
node_map[node.get_id()] = Some(node.clone());
}
}
false => {
let node_children_ids = node.get_children().collect_vec();
for child_id in &node_children_ids {
Expand Down
23 changes: 12 additions & 11 deletions src/tree/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ pub trait ContractTree: EulerWalk + DFS {
.map(|x| self.get_node(x).cloned().unwrap())
.for_each(|mut node| {
match node.is_leaf() {
true => if leaf_ids.contains(&node.get_id()) {
node_map.insert(node.get_id(), node);
},
true => {
if leaf_ids.contains(&node.get_id()) {
node_map.insert(node.get_id(), node);
}
}
false => {
let node_children_ids = node.get_children().collect_vec();
for child_id in &node_children_ids {
Expand Down Expand Up @@ -197,9 +199,11 @@ pub trait ContractTree: EulerWalk + DFS {
node_postord_iter.for_each(|orig_node| {
let mut node = orig_node.clone();
match node.is_leaf() {
true => if leaf_ids.contains(&node.get_id()) {
node_map.insert(node.get_id(), node);
},
true => {
if leaf_ids.contains(&node.get_id()) {
node_map.insert(node.get_id(), node);
}
}
false => {
let node_children_ids = node.get_children().collect_vec();
for child_id in &node_children_ids {
Expand Down Expand Up @@ -246,11 +250,8 @@ pub trait ContractTree: EulerWalk + DFS {
// add grandchildren to node children
// set grandchildren parent to node
node.remove_child(&chid);
let node_grandchildren = node_map
.get(&chid)
.unwrap()
.get_children()
.collect_vec();
let node_grandchildren =
node_map.get(&chid).unwrap().get_children().collect_vec();
for grandchild in node_grandchildren {
node.add_child(grandchild);
node_map
Expand Down
4 changes: 1 addition & 3 deletions tests/tree-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,10 @@ fn cluster_affinity() {
let input_str: String = String::from("(A,(D,(C,B)));");
let t2 = SimpleRootedTree::from_newick(input_str.as_bytes()).unwrap();
assert_eq!(t1.ca(&t2), 2);

}

#[test]
fn bipartitions(){
fn bipartitions() {
let input_str: String = String::from("(((A,B),C),D);");
let t1 = SimpleRootedTree::from_newick(input_str.as_bytes()).unwrap();
let _bps = t1
Expand Down Expand Up @@ -281,5 +280,4 @@ fn bipartitions(){
)
})
.collect_vec();

}

0 comments on commit 47aee59

Please sign in to comment.