Skip to content

Commit 59eb1a9

Browse files
committed
Use degree to size adjacency lists
``` adjacency_list_all_targets/large_Outgoing_Unsorted time: [14.010 ms 14.154 ms 14.305 ms] change: [-36.246% -35.180% -34.199%] (p = 0.00 < 0.05) Performance has improved. ```
1 parent 23e805a commit 59eb1a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/builder/src/graph/adj_list.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,14 @@ where
203203
(edge_list, node_count, direction, csr_layout): (&'_ E, NI, Direction, CsrLayout),
204204
) -> Self {
205205
let start = Instant::now();
206-
let mut thread_safe_vec = Vec::with_capacity(node_count.index());
207-
thread_safe_vec.resize_with(node_count.index(), || Mutex::new(Vec::new()));
208-
let thread_safe_vec = thread_safe_vec;
206+
let thread_safe_vec = edge_list
207+
.degrees(node_count, direction)
208+
.into_par_iter()
209+
.map(|degree| Mutex::new(Vec::with_capacity(degree.into_inner().index())))
210+
.collect::<Vec<_>>();
211+
info!("Initialized adjacency list in {:?}", start.elapsed());
209212

213+
let start = Instant::now();
210214
edge_list.edges().for_each(|(s, t, v)| {
211215
if matches!(direction, Direction::Outgoing | Direction::Undirected) {
212216
thread_safe_vec[s.index()]

0 commit comments

Comments
 (0)