This commit is contained in:
parent
d3bade1bdd
commit
237ca36381
10
src/day23.rs
10
src/day23.rs
@ -71,12 +71,12 @@ impl Network {
|
|||||||
let mut new_r = r.clone();
|
let mut new_r = r.clone();
|
||||||
new_r.insert(*node);
|
new_r.insert(*node);
|
||||||
|
|
||||||
let neighbours = FxHashSet::from_iter(self.edges.get(&node).unwrap().iter().map(|n| *n));
|
let neighbours = FxHashSet::from_iter(self.edges.get(node).unwrap().iter().copied());
|
||||||
let new_p = FxHashSet::from_iter(p.intersection(&neighbours).map(|n| *n));
|
let new_p = FxHashSet::from_iter(p.intersection(&neighbours).copied());
|
||||||
let new_x = FxHashSet::from_iter(x.intersection(&neighbours).map(|n| *n));
|
let new_x = FxHashSet::from_iter(x.intersection(&neighbours).copied());
|
||||||
|
|
||||||
results.extend(self.bron_kerbosch(new_r, new_p, new_x).into_iter());
|
results.extend(self.bron_kerbosch(new_r, new_p, new_x).into_iter());
|
||||||
p.remove(&node);
|
p.remove(node);
|
||||||
x.insert(*node);
|
x.insert(*node);
|
||||||
}
|
}
|
||||||
results
|
results
|
||||||
@ -84,7 +84,7 @@ impl Network {
|
|||||||
fn maximal_subgraphs(&self) -> Vec<FxHashSet<Node>> {
|
fn maximal_subgraphs(&self) -> Vec<FxHashSet<Node>> {
|
||||||
self.bron_kerbosch(
|
self.bron_kerbosch(
|
||||||
FxHashSet::default(),
|
FxHashSet::default(),
|
||||||
FxHashSet::from_iter(self.nodes.iter().map(|n| *n)),
|
FxHashSet::from_iter(self.nodes.iter().copied()),
|
||||||
FxHashSet::default(),
|
FxHashSet::default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user