use super::{WeightedPath, bfs, dijkstra};
use crate::{IndexGraphView, Vec};
use rayon::prelude::*;
#[must_use]
pub fn bfs_batch_parallel<G>(graph: &G, starts: &[G::Node]) -> Vec<Vec<G::Node>>
where
G: IndexGraphView + Sync,
G::Node: Send + Sync,
{
starts.par_iter().map(|&start| bfs(graph, start)).collect()
}
#[must_use]
pub fn dijkstra_batch_parallel<G, F>(
graph: &G,
queries: &[(G::Node, G::Node)],
edge_cost: F,
) -> Vec<Option<WeightedPath<G::Node>>>
where
G: IndexGraphView + Sync,
G::Node: Send + Sync,
G::Edge: Send,
F: Fn(G::Edge) -> u64 + Send + Sync,
{
queries
.par_iter()
.map(|&(source, target)| dijkstra(graph, source, target, &edge_cost))
.collect()
}