Created
July 23, 2018 01:48
-
-
Save rust-play/c673d064a88ea4183afe502c9d4121c5 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut db = DBSCAN::new(1.5, 5); | |
db.train(&jaccard_matrix).unwrap(); | |
let cluster_assignments = db.clusters().unwrap(); | |
let mut clusters = Vec::<Vec::<usize>>::new(); | |
for (i,assignment) in cluster_assignments.iter().enumerate() { | |
if assignment.is_some(){ | |
let val = assignment.unwrap(); | |
println!("read {}: cluster {}", read_ids[i], val ); | |
if clusters.len() < val{ | |
clusters.push(vec![i]) | |
} | |
else{ | |
clusters[val].push(i) | |
} | |
} | |
} | |
for (i,cluster) in clusters.iter().enumerate(){ | |
println!("Cluster {}:", i); | |
for index in cluster.iter(){ | |
println!("\t{}",read_ids[index]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment