From 88f51228bd017992e86294e2e64b4b7c9a7cb908 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Wed, 24 Apr 2024 15:41:34 +0200 Subject: [PATCH 01/12] Remove the Hashmap of the katz centrality computation to avoid better performance --- rustworkx-core/src/centrality.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 35683bbc8e..65ed36a5f5 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -738,23 +738,18 @@ where { let alpha: f64 = alpha.unwrap_or(0.1); - let mut beta: HashMap = beta_map.unwrap_or_default(); - - if beta.is_empty() { - // beta_map was none - // populate hashmap with default value - let beta_scalar = beta_scalar.unwrap_or(1.0); - for node_index in graph.node_identifiers() { - let node = graph.to_index(node_index); - beta.insert(node, beta_scalar); - } - } else { + let beta: HashMap = beta_map.unwrap_or_default(); + //Initialize the beta vector in case a beta map was not provided + let mut beta_v = vec![beta_scalar.unwrap_or(1.0); graph.node_bound()]; + + if !beta.is_empty() { // Check if beta contains all node indices for node_index in graph.node_identifiers() { let node = graph.to_index(node_index); if !beta.contains_key(&node) { return Ok(None); // beta_map was provided but did not include all nodes } + beta_v[node] = *beta.get(&node).unwrap(); //Initialize the beta vector with the provided values } } @@ -776,7 +771,7 @@ where } for node_index in graph.node_identifiers() { let node = graph.to_index(node_index); - x[node] = alpha * x[node] + beta.get(&node).unwrap_or(&0.0); + x[node] = alpha * x[node] + beta_v[node]; } if (0..x.len()) .map(|node| (x[node] - x_last[node]).abs()) From 3087023489817fc07c825b3ab8696d63cbca34a7 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Wed, 24 Apr 2024 16:18:54 +0200 Subject: [PATCH 02/12] cargo fmt --- rustworkx-core/src/centrality.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 65ed36a5f5..09e21affac 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -740,8 +740,8 @@ where let beta: HashMap = beta_map.unwrap_or_default(); //Initialize the beta vector in case a beta map was not provided - let mut beta_v = vec![beta_scalar.unwrap_or(1.0); graph.node_bound()]; - + let mut beta_v = vec![beta_scalar.unwrap_or(1.0); graph.node_bound()]; + if !beta.is_empty() { // Check if beta contains all node indices for node_index in graph.node_identifiers() { From 15cec7825a3b5d2175c22a87c53c07555ba15750 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Sun, 3 Nov 2024 19:49:53 +0100 Subject: [PATCH 03/12] Remove the Hashmap from the ShortestPath_for_centrality computation --- rustworkx-core/src/centrality.rs | 47 +++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 09e21affac..227d738eea 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -353,35 +353,50 @@ where { let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors = HashMap::>::with_capacity(c); - let mut sigma = HashMap::::with_capacity(c); - let mut distance = HashMap::::with_capacity(c); + let mut predecessors: Vec> = Vec::with_capacity(c); + let mut sigma: Vec = Vec::with_capacity(c); + let mut distance: Vec = Vec::with_capacity(c); #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); - for node in graph.node_identifiers() { - predecessors.insert(node, Vec::new()); - sigma.insert(node, 0.0); - distance.insert(node, -1); + let node_index = graph.to_index(node); + predecessors[node_index] = Vec::new(); + sigma[node_index] = 0.0; + distance[node_index] = -1; } - sigma.insert(*node_s, 1.0); - distance.insert(*node_s, 0); + let node_s_index = graph.to_index(*node_s); + sigma[node_s_index] = 1.0; + distance[node_s_index] = 0; Q.push_back(*node_s); while let Some(v) = Q.pop_front() { verts_sorted_by_distance.push(v); - let distance_v = distance[&v]; + let v_idx = graph.to_index(v); + let distance_v = distance[v_idx]; for w in graph.neighbors(v) { - if distance[&w] < 0 { + let w_idx = graph.to_index(w); + if distance[w_idx] < 0 { Q.push_back(w); - distance.insert(w, distance_v + 1); + distance[w_idx] = distance_v + 1; } - if distance[&w] == distance_v + 1 { - sigma.insert(w, sigma[&w] + sigma[&v]); - let e_p = predecessors.get_mut(&w).unwrap(); - e_p.push(v); + if distance[w_idx] == distance_v + 1 { + sigma[w_idx] = sigma[w_idx] + sigma[v_idx]; + predecessors[w_idx].push(v); } } } + let mut sigma_h = HashMap::with_capacity(c); + for (idx, s) in sigma.iter().enumerate() { + sigma_h.insert(graph.from_index(idx), *s); + } + let mut pred_h = HashMap::with_capacity(c); + let mut idx = predecessors.len() - 1; + + while let Some(p) = predecessors.pop() { + pred_h.insert(graph.from_index(idx), p); + idx -= 1; + } + let sigma = sigma_h; + let predecessors = pred_h; verts_sorted_by_distance.reverse(); // will be effectively popping from the stack ShortestPathData { verts_sorted_by_distance, From 0a2b549aac62e7e61c3876054a6ab19007a86a09 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Sun, 3 Nov 2024 19:59:47 +0100 Subject: [PATCH 04/12] clippy advice --- rustworkx-core/src/centrality.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 227d738eea..7bc542ff2a 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -379,7 +379,7 @@ where distance[w_idx] = distance_v + 1; } if distance[w_idx] == distance_v + 1 { - sigma[w_idx] = sigma[w_idx] + sigma[v_idx]; + sigma[w_idx] += sigma[v_idx]; predecessors[w_idx].push(v); } } From a6d8171e1d4bfb30616e63d74ba0d7ef7eef3273 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Sun, 3 Nov 2024 20:09:44 +0100 Subject: [PATCH 05/12] Fix --- rustworkx-core/src/centrality.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 7bc542ff2a..fedb826388 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -353,17 +353,11 @@ where { let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors: Vec> = Vec::with_capacity(c); - let mut sigma: Vec = Vec::with_capacity(c); - let mut distance: Vec = Vec::with_capacity(c); + let mut predecessors: Vec> = vec![Vec::new();c]; + let mut sigma: Vec = vec![0.;c]; + let mut distance: Vec = vec![-1;c]; #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); - for node in graph.node_identifiers() { - let node_index = graph.to_index(node); - predecessors[node_index] = Vec::new(); - sigma[node_index] = 0.0; - distance[node_index] = -1; - } let node_s_index = graph.to_index(*node_s); sigma[node_s_index] = 1.0; distance[node_s_index] = 0; @@ -389,11 +383,11 @@ where sigma_h.insert(graph.from_index(idx), *s); } let mut pred_h = HashMap::with_capacity(c); - let mut idx = predecessors.len() - 1; + let mut idx = predecessors.len(); while let Some(p) = predecessors.pop() { - pred_h.insert(graph.from_index(idx), p); idx -= 1; + pred_h.insert(graph.from_index(idx), p); } let sigma = sigma_h; let predecessors = pred_h; From 70322a089f4eea97fd7addadafbe1ef687eb5a76 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Sun, 3 Nov 2024 20:10:38 +0100 Subject: [PATCH 06/12] fmt --- rustworkx-core/src/centrality.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index fedb826388..93c1e23078 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -353,9 +353,9 @@ where { let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors: Vec> = vec![Vec::new();c]; - let mut sigma: Vec = vec![0.;c]; - let mut distance: Vec = vec![-1;c]; + let mut predecessors: Vec> = vec![Vec::new(); c]; + let mut sigma: Vec = vec![0.; c]; + let mut distance: Vec = vec![-1; c]; #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); let node_s_index = graph.to_index(*node_s); From 00af4af638543cd531a79ddc5471dc2ac9e5625f Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Mon, 4 Nov 2024 00:12:05 +0100 Subject: [PATCH 07/12] Fix python test --- rustworkx-core/src/centrality.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 93c1e23078..863a3c5955 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -345,17 +345,17 @@ where predecessors: HashMap>, sigma: HashMap, } - fn shortest_path_for_centrality(graph: G, node_s: &G::NodeId) -> ShortestPathData where G: NodeIndexable + IntoNodeIdentifiers + IntoNeighborsDirected + NodeCount + GraphBase, ::NodeId: std::cmp::Eq + Hash, { - let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors: Vec> = vec![Vec::new(); c]; - let mut sigma: Vec = vec![0.; c]; - let mut distance: Vec = vec![-1; c]; + let max_index = graph.node_bound(); + let mut verts_sorted_by_distance: Vec = Vec::with_capacity(c); // a stack + let mut predecessors: Vec> = vec![Vec::new(); max_index]; + let mut sigma: Vec = vec![0.; max_index]; + let mut distance: Vec = vec![-1; max_index]; #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); let node_s_index = graph.to_index(*node_s); From d65c34eac797844ecfd60bfc46d8b9bb9b831e7a Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Mon, 4 Nov 2024 11:06:42 +0100 Subject: [PATCH 08/12] Remove Hashmap from accumulate vertice too --- rustworkx-core/src/centrality.rs | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 863a3c5955..f73c41b4e0 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -280,11 +280,11 @@ fn _accumulate_vertices( let mut delta = vec![0.0; max_index]; for w in &path_calc.verts_sorted_by_distance { let iw = graph.to_index(*w); - let coeff = (1.0 + delta[iw]) / path_calc.sigma[w]; - let p_w = path_calc.predecessors.get(w).unwrap(); - for v in p_w { - let iv = graph.to_index(*v); - delta[iv] += path_calc.sigma[v] * coeff; + let coeff = (1.0 + delta[iw]) / path_calc.sigma[iw]; + let p_w = path_calc.predecessors.get(iw).unwrap(); + for iv in p_w { + //let iv = graph.to_index(*v); + delta[*iv] += path_calc.sigma[*iv] * coeff; } } let mut betweenness = locked_betweenness.write().unwrap(); @@ -342,8 +342,8 @@ where ::NodeId: std::cmp::Eq + Hash, { verts_sorted_by_distance: Vec, - predecessors: HashMap>, - sigma: HashMap, + predecessors: Vec>, + sigma: Vec, } fn shortest_path_for_centrality(graph: G, node_s: &G::NodeId) -> ShortestPathData where @@ -353,7 +353,7 @@ where let c = graph.node_count(); let max_index = graph.node_bound(); let mut verts_sorted_by_distance: Vec = Vec::with_capacity(c); // a stack - let mut predecessors: Vec> = vec![Vec::new(); max_index]; + let mut predecessors: Vec> = vec![Vec::new(); max_index]; let mut sigma: Vec = vec![0.; max_index]; let mut distance: Vec = vec![-1; max_index]; #[allow(non_snake_case)] @@ -374,23 +374,10 @@ where } if distance[w_idx] == distance_v + 1 { sigma[w_idx] += sigma[v_idx]; - predecessors[w_idx].push(v); + predecessors[w_idx].push(v_idx); } } } - let mut sigma_h = HashMap::with_capacity(c); - for (idx, s) in sigma.iter().enumerate() { - sigma_h.insert(graph.from_index(idx), *s); - } - let mut pred_h = HashMap::with_capacity(c); - let mut idx = predecessors.len(); - - while let Some(p) = predecessors.pop() { - idx -= 1; - pred_h.insert(graph.from_index(idx), p); - } - let sigma = sigma_h; - let predecessors = pred_h; verts_sorted_by_distance.reverse(); // will be effectively popping from the stack ShortestPathData { verts_sorted_by_distance, From 55a8b91e10bf8e7168a50b7acaddd471eba055cd Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Fri, 8 Nov 2024 17:04:10 +0100 Subject: [PATCH 09/12] Remove useless comment --- rustworkx-core/src/centrality.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index f73c41b4e0..9978bcc57f 100644 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -283,7 +283,6 @@ fn _accumulate_vertices( let coeff = (1.0 + delta[iw]) / path_calc.sigma[iw]; let p_w = path_calc.predecessors.get(iw).unwrap(); for iv in p_w { - //let iv = graph.to_index(*v); delta[*iv] += path_calc.sigma[*iv] * coeff; } } From 83707e04229f0eee46f4228c0609224fce9a43e5 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Tue, 13 May 2025 23:10:44 +0200 Subject: [PATCH 10/12] Remove hashmap for betwenness with edge too and clean the code --- rustworkx-core/src/centrality.rs | 78 +++++++++++++++----------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index eb104ec42f..1dcf407b4f 100755 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -79,7 +79,7 @@ where + GraphProp + GraphBase + std::marker::Sync, - ::NodeId: std::cmp::Eq + Hash + Send, + ::NodeId: std::cmp::Eq + Send, // rustfmt deletes the following comments if placed inline above // + IntoNodeIdentifiers // for node_identifiers() // + IntoNeighborsDirected // for neighbors() @@ -184,8 +184,8 @@ where + EdgeCount + GraphProp + Sync, - G::NodeId: Eq + Hash + Send, - G::EdgeId: Eq + Hash + Send, + G::NodeId: Eq + Send, + G::EdgeId: Eq + Send, { let max_index = graph.node_bound(); let mut betweenness = vec![None; graph.edge_bound()]; @@ -264,7 +264,7 @@ fn _accumulate_vertices( + GraphProp + GraphBase + std::marker::Sync, - ::NodeId: std::cmp::Eq + Hash, + ::NodeId: std::cmp::Eq, { let mut delta = vec![0.0; max_index]; for w in &path_calc.verts_sorted_by_distance { @@ -303,21 +303,21 @@ fn accumulate_edges( graph: G, ) where G: NodeIndexable + EdgeIndexable + Sync, - G::NodeId: Eq + Hash, - G::EdgeId: Eq + Hash, + G::NodeId: Eq, + G::EdgeId: Eq, { let mut delta = vec![0.0; max_index]; for w in &path_calc.verts_sorted_by_distance { let iw = NodeIndexable::to_index(&graph, *w); - let coeff = (1.0 + delta[iw]) / path_calc.sigma[w]; - let p_w = path_calc.predecessors.get(w).unwrap(); - let e_w = path_calc.predecessor_edges.get(w).unwrap(); + let coeff = (1.0 + delta[iw]) / path_calc.sigma[iw]; + let p_w = path_calc.predecessors.get(iw).unwrap(); + let e_w = path_calc.predecessor_edges.get(iw).unwrap(); let mut betweenness = locked_betweenness.write().unwrap(); for i in 0..p_w.len() { let v = p_w[i]; let iv = NodeIndexable::to_index(&graph, v); let ie = EdgeIndexable::to_index(&graph, e_w[i]); - let c = path_calc.sigma[&v] * coeff; + let c = path_calc.sigma[iv] * coeff; betweenness[ie] = betweenness[ie].map(|x| x + c); delta[iv] += c; } @@ -357,7 +357,7 @@ where + IntoNeighborsDirected + NodeCount + GraphProp, - G::NodeId: Eq + Hash, + G::NodeId: Eq, { let node_count = graph.node_count() as f64; let mut centrality = vec![0.0; graph.node_bound()]; @@ -395,7 +395,7 @@ where struct ShortestPathData where G: GraphBase, - ::NodeId: std::cmp::Eq + Hash, + ::NodeId: std::cmp::Eq, { verts_sorted_by_distance: Vec, predecessors: Vec>, @@ -404,7 +404,7 @@ where fn shortest_path_for_centrality(graph: G, node_s: &G::NodeId) -> ShortestPathData where G: NodeIndexable + IntoNodeIdentifiers + IntoNeighborsDirected + NodeCount + GraphBase, - ::NodeId: std::cmp::Eq + Hash, + ::NodeId: std::cmp::Eq, { let c = graph.node_count(); let max_index = graph.node_bound(); @@ -445,13 +445,13 @@ where struct ShortestPathDataWithEdges where G: GraphBase, - G::NodeId: Eq + Hash, - G::EdgeId: Eq + Hash, + G::NodeId: Eq, + G::EdgeId: Eq, { verts_sorted_by_distance: Vec, - predecessors: HashMap>, - predecessor_edges: HashMap>, - sigma: HashMap, + predecessors: Vec>, + predecessor_edges: Vec>, + sigma: Vec, } fn shortest_path_for_edge_centrality( @@ -465,41 +465,37 @@ where + NodeCount + GraphBase + IntoEdges, - G::NodeId: Eq + Hash, - G::EdgeId: Eq + Hash, + G::NodeId: Eq, + G::EdgeId: Eq, { let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors = HashMap::>::with_capacity(c); - let mut predecessor_edges = HashMap::>::with_capacity(c); - let mut sigma = HashMap::::with_capacity(c); - let mut distance = HashMap::::with_capacity(c); + let mut predecessors = vec![Vec::new();c]; + let mut predecessor_edges = vec![Vec::new();c]; + let mut sigma = vec![0.0;c]; + let mut distance = vec![-1;c]; #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); - for node in graph.node_identifiers() { - predecessors.insert(node, Vec::new()); - predecessor_edges.insert(node, Vec::new()); - sigma.insert(node, 0.0); - distance.insert(node, -1); - } - sigma.insert(*node_s, 1.0); - distance.insert(*node_s, 0); + sigma[graph.to_index(*node_s)] = 1.; + distance[graph.to_index(*node_s)] = 0; Q.push_back(*node_s); while let Some(v) = Q.pop_front() { verts_sorted_by_distance.push(v); - let distance_v = distance[&v]; + let v_index = graph.to_index(v); + let distance_v = distance[v_index]; for edge in graph.edges(v) { let w = edge.target(); - if distance[&w] < 0 { + let w_index = graph.to_index(w); + if distance[w_index] < 0 { Q.push_back(w); - distance.insert(w, distance_v + 1); + distance[w_index] = distance_v + 1; } - if distance[&w] == distance_v + 1 { - sigma.insert(w, sigma[&w] + sigma[&v]); - let e_p = predecessors.get_mut(&w).unwrap(); + if distance[w_index] == distance_v + 1 { + sigma[w_index] = sigma[w_index] + sigma[v_index]; + let e_p = predecessors.get_mut(w_index).unwrap(); e_p.push(v); - predecessor_edges.get_mut(&w).unwrap().push(edge.id()); + predecessor_edges.get_mut(w_index).unwrap().push(edge.id()); } } } @@ -689,7 +685,7 @@ pub fn eigenvector_centrality( ) -> Result>, E> where G: NodeIndexable + IntoNodeIdentifiers + IntoNeighbors + IntoEdges + NodeCount, - G::NodeId: Eq + std::hash::Hash, + G::NodeId: Eq, F: FnMut(G::EdgeRef) -> Result, { let tol: f64 = tol.unwrap_or(1e-6); @@ -785,7 +781,7 @@ pub fn katz_centrality( ) -> Result>, E> where G: NodeIndexable + IntoNodeIdentifiers + IntoNeighbors + IntoEdges + NodeCount, - G::NodeId: Eq + std::hash::Hash, + G::NodeId: Eq, F: FnMut(G::EdgeRef) -> Result, { let alpha: f64 = alpha.unwrap_or(0.1); From f0b14f25f502d9ccc4c3d35d678881a94778db01 Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Tue, 13 May 2025 23:13:02 +0200 Subject: [PATCH 11/12] fmt --- rustworkx-core/src/centrality.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index 1dcf407b4f..d6751f2d16 100755 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -79,7 +79,7 @@ where + GraphProp + GraphBase + std::marker::Sync, - ::NodeId: std::cmp::Eq + Send, + ::NodeId: std::cmp::Eq + Send, // rustfmt deletes the following comments if placed inline above // + IntoNodeIdentifiers // for node_identifiers() // + IntoNeighborsDirected // for neighbors() @@ -470,10 +470,10 @@ where { let mut verts_sorted_by_distance: Vec = Vec::new(); // a stack let c = graph.node_count(); - let mut predecessors = vec![Vec::new();c]; - let mut predecessor_edges = vec![Vec::new();c]; - let mut sigma = vec![0.0;c]; - let mut distance = vec![-1;c]; + let mut predecessors = vec![Vec::new(); c]; + let mut predecessor_edges = vec![Vec::new(); c]; + let mut sigma = vec![0.0; c]; + let mut distance = vec![-1; c]; #[allow(non_snake_case)] let mut Q: VecDeque = VecDeque::with_capacity(c); From 26feeef55772ae2515a1715fdde57810c29a820e Mon Sep 17 00:00:00 2001 From: Paulo-21 Date: Wed, 14 May 2025 00:11:51 +0200 Subject: [PATCH 12/12] Fix clippy --- rustworkx-core/src/centrality.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustworkx-core/src/centrality.rs b/rustworkx-core/src/centrality.rs index d6751f2d16..87bc0b062e 100755 --- a/rustworkx-core/src/centrality.rs +++ b/rustworkx-core/src/centrality.rs @@ -492,7 +492,7 @@ where distance[w_index] = distance_v + 1; } if distance[w_index] == distance_v + 1 { - sigma[w_index] = sigma[w_index] + sigma[v_index]; + sigma[w_index] += sigma[v_index]; let e_p = predecessors.get_mut(w_index).unwrap(); e_p.push(v); predecessor_edges.get_mut(w_index).unwrap().push(edge.id());