Skip to content

Commit 49a24ee

Browse files
committed
clippy
1 parent 01b0684 commit 49a24ee

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

2024/day23/day23.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::{HashMap, HashSet};
66
// Bron-Kerbosch recursive algorithm to find cliques
77
fn bron_kerbosch(
88
graph: &UnGraph<(), ()>,
9-
r: &mut HashSet<NodeIndex>,
9+
r: &HashSet<NodeIndex>,
1010
p: &mut HashSet<NodeIndex>,
1111
x: &mut HashSet<NodeIndex>,
1212
cliques: &mut Vec<Vec<NodeIndex>>,
@@ -25,7 +25,7 @@ fn bron_kerbosch(
2525
let mut p_new: HashSet<NodeIndex> = p.intersection(&neighbors).copied().collect();
2626
let mut x_new: HashSet<NodeIndex> = x.intersection(&neighbors).copied().collect();
2727

28-
bron_kerbosch(graph, &mut r_new, &mut p_new, &mut x_new, cliques);
28+
bron_kerbosch(graph, &r_new, &mut p_new, &mut x_new, cliques);
2929

3030
p.remove(&v);
3131
x.insert(v);
@@ -37,7 +37,7 @@ struct Puzzle {
3737
}
3838

3939
impl Puzzle {
40-
fn new() -> Self {
40+
const fn new() -> Self {
4141
Self {
4242
connections: Vec::new(),
4343
}
@@ -95,18 +95,6 @@ impl Puzzle {
9595

9696
/// Solve part two.
9797
fn part2(&self) -> String {
98-
// type G = Graph<(), (), Undirected>;
99-
100-
// let mut graph = G::new_undirected();
101-
// let mut nodes = HashMap::new();
102-
103-
// for (n1, n2) in &self.connections {
104-
// let i1 = *nodes.entry(n1).or_insert_with(|| graph.add_node(()));
105-
// let i2 = *nodes.entry(n2).or_insert_with(|| graph.add_node(()));
106-
107-
// graph.add_edge(i1, i2, ());
108-
// }
109-
11098
let mut graph = UnGraph::<(), ()>::new_undirected();
11199

112100
let mut nodes = HashMap::new();
@@ -128,11 +116,11 @@ impl Puzzle {
128116

129117
// find the largest clique
130118
let mut cliques = Vec::new();
131-
let mut r = HashSet::new();
119+
let r = HashSet::new();
132120
let mut p: HashSet<NodeIndex> = graph.node_indices().collect();
133121
let mut x = HashSet::new();
134122

135-
bron_kerbosch(&graph, &mut r, &mut p, &mut x, &mut cliques);
123+
bron_kerbosch(&graph, &r, &mut p, &mut x, &mut cliques);
136124

137125
let largest_clique = cliques.into_iter().max_by_key(std::vec::Vec::len);
138126

@@ -143,7 +131,7 @@ impl Puzzle {
143131
.collect::<Vec<_>>();
144132
clique_names.sort_unstable();
145133

146-
return clique_names.join(",").to_string();
134+
return clique_names.join(",");
147135
}
148136

149137
String::new()

0 commit comments

Comments
 (0)