Start to implement K-clustering
parent
a13fae6ceb
commit
12f8f2cf43
|
@ -17,3 +17,6 @@ algos.sublime-workspace
|
|||
# Data for the exercises. Some files are big so don't check them in.
|
||||
data/c2a4.txt
|
||||
data/c2a4.back.txt
|
||||
data/c3a2_clustering.txt
|
||||
data/c3a2_clustering_big.txt
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 226 KiB |
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
|
@ -0,0 +1,10 @@
|
|||
use crate::prims::WeightedGraph;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn k_clustering(graph: &WeightedGraph) -> i32 {
|
||||
for vertex in graph {
|
||||
println!("{:?}", vertex.edges.len());
|
||||
}
|
||||
graph.len().try_into().unwrap()
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ mod quick_sort;
|
|||
mod ssc;
|
||||
mod two_sum;
|
||||
mod util;
|
||||
mod k_clustering;
|
||||
|
||||
use crate::dijkstra::dijkstra;
|
||||
use crate::heap::heap;
|
||||
|
@ -18,6 +19,7 @@ use crate::prims::prims;
|
|||
use crate::quick_sort::quick_sort;
|
||||
use crate::ssc::ssc;
|
||||
use crate::two_sum::find_two_sums;
|
||||
use crate::k_clustering::k_clustering;
|
||||
use std::cmp::min;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -103,7 +105,9 @@ fn c3a1() {
|
|||
|
||||
#[allow(dead_code)]
|
||||
fn c3a2() {
|
||||
println!("let's go");
|
||||
let graph = util::read_weighted_graph("data/c3a2_clustering.txt").unwrap();
|
||||
let r1 = k_clustering(&graph);
|
||||
println!("r1 = {:?}", r1);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
Loading…
Reference in New Issue