Skip to content

Commit

Permalink
Fix #362
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Mar 7, 2024
1 parent f33dc33 commit 9a0bfb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggraph (development version)

* Fixed a bug in the collapse functionality of `get_edges()` (#362)

# ggraph 2.2.1

* Rolling back use of native pipe (#364 and #365)
Expand Down
18 changes: 2 additions & 16 deletions R/edges.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,24 +203,10 @@ collapse_all_edges <- function(edges) {
from <- pmin(edges$from, edges$to)
to <- pmax(edges$to, edges$from)
id <- paste(from, to, sep = '-')
if (anyDuplicated(id)) {
edges$.id <- id
edges <- edges %>%
group_by(.data$.id) %>%
top_n(1) %>%
ungroup()
}
data_frame0(edges)
edges[!duplicated(id), , drop = FALSE]
}
#' @importFrom dplyr group_by top_n ungroup
collapse_dir_edges <- function(edges) {
id <- paste(edges$from, edges$to, sep = '-')
if (anyDuplicated(id)) {
edges$.id <- id
edges <- edges %>%
group_by(.data$.id) %>%
top_n(1) %>%
ungroup()
}
data_frame0(edges)
edges[!duplicated(id), , drop = FALSE]
}

0 comments on commit 9a0bfb1

Please sign in to comment.