Skip to content

Commit

Permalink
Test MST's cost
Browse files Browse the repository at this point in the history
  • Loading branch information
EbTech committed Jun 9, 2017
1 parent c9511c6 commit 4a45615
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ mod test {
graph.add_undirected_edge(1, 2);
graph.add_undirected_edge(2, 0);
let weights = [7, 3, 5];
assert_eq!(graph.min_spanning_tree(&weights), vec![1, 2]);
let mst = graph.min_spanning_tree(&weights);
let mst_cost = mst.iter().map(|&e| weights[e]).sum::<i64>();
assert_eq!(mst, vec![1, 2]);
assert_eq!(mst_cost, 8);
}
}

0 comments on commit 4a45615

Please sign in to comment.