Reduces a weighted edge list by removing weak or excess edges.
Examples
edges <- data.frame(
from = c("A","A","A","B","B","C"),
to = c("B","C","D","C","D","D"),
weight = c(5, 1, 2, 4, 1, 3)
)
# Keep only edges with weight >= 3
prune(edges, threshold = 3)
#> from to weight
#> 1 A B 5
#> 2 B C 4
#> 3 C D 3
# Keep the 2 strongest edges per node
prune(edges, top_n = 2)
#> from to weight
#> 1 A B 5
#> 2 B C 4
#> 3 C D 3
#> 4 A D 2