Fix inconsistency in day 23.

It works way better when you choose an optimal pivot.
This commit is contained in:
2018-12-25 13:32:08 +01:00
parent ff36f15ae1
commit c05b486033
3 changed files with 29 additions and 28 deletions

View File

@@ -42,7 +42,7 @@ fn bron_kerbosch1(graph: Graph, cliques: &mut Vec<NodeSet>, r: &mut NodeSet, p:
}
let mut p_clone = p.clone();
let pivot = *p.union(&x).next().unwrap();
let pivot = *p.union(&x).max_by_key(|&&v| graph[v].len()).unwrap();
for &v in p.difference(&graph[pivot]) {
r.insert(v);