library(dplyr)
# Solve both problems with grouped workflow
example_df |>
group_by(sim) |>
lap_solve(source, target, cost)
# Batch solving for efficiency
example_df |>
group_by(sim) |>
lap_solve_batch(source, target, cost)
# Inspect the data structure
example_df |>
group_by(sim) |>
summarise(
n_pairs = n(),
min_cost = min(cost),
max_cost = max(cost)
)
Run the code above in your browser using DataLab