Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/map.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ map_local_dbl <- function(order = 1, mode = 'all', mindist = 0, .f, ...) {
#' @importFrom tibble tibble
bfs_df <- function(graph, root, mode, unreachable) {
search <- bfs(graph = graph, root = root, mode = mode, unreachable = unreachable,
order = TRUE, rank = TRUE, father = TRUE, pred = TRUE,
order = TRUE, rank = TRUE, parent = TRUE, pred = TRUE,
succ = TRUE, dist = TRUE)
nodes <- seq_along(search$order)
tibble(
node = nodes,
rank = as.integer(search$rank),
parent = as.integer(search$father),
parent = as.integer(search$parent),
before = as.integer(search$pred),
after = as.integer(search$succ),
dist = as.integer(search$dist),
Expand All @@ -438,13 +438,13 @@ bfs_df <- function(graph, root, mode, unreachable) {
#' @importFrom tibble tibble
dfs_df <- function(graph, root, mode, unreachable) {
search <- dfs(graph = graph, root = root, mode = mode, unreachable = unreachable,
order = TRUE, order.out = TRUE, father = TRUE, dist = TRUE)
order = TRUE, order.out = TRUE, parent = TRUE, dist = TRUE)
nodes <- seq_along(search$order)
tibble(
node = nodes,
rank = match(nodes, as.integer(search$order)),
rank_out = match(nodes, as.integer(search$order.out)),
parent = as.integer(search$father),
parent = as.integer(search$parent),
dist = as.integer(search$dist),
result = rep(list(NULL), length(nodes))
)
Expand Down
6 changes: 3 additions & 3 deletions R/morphers.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ to_shortest_path <- function(graph, from, to, mode = 'out', weights = NULL) {
to_bfs_tree <- function(graph, root, mode = 'out', unreachable = FALSE) {
root <- eval_tidy(enquo(root), as_tibble(graph, 'nodes'))
root <- as_node_ind(root, graph)
search <- bfs(graph, root, mode = mode, unreachable = unreachable, father = TRUE)
search <- bfs(graph, root, mode = mode, unreachable = unreachable, parent = TRUE)
bfs_graph <- search_to_graph(graph, search)
list(
bfs = bfs_graph
Expand All @@ -230,7 +230,7 @@ to_bfs_tree <- function(graph, root, mode = 'out', unreachable = FALSE) {
to_dfs_tree <- function(graph, root, mode = 'out', unreachable = FALSE) {
root <- eval_tidy(enquo(root), as_tibble(graph, 'nodes'))
root <- as_node_ind(root, graph)
search <- dfs(graph, root, mode = mode, unreachable = unreachable, father = TRUE)
search <- dfs(graph, root, mode = mode, unreachable = unreachable, parent = TRUE)
dfs_graph <- search_to_graph(graph, search)
list(
dfs = dfs_graph
Expand Down Expand Up @@ -340,7 +340,7 @@ to_hierarchical_clusters <- function(graph, method = 'walktrap', weights = NULL,

search_to_graph <- function(graph, search) {
nodes <- as_tibble(graph, active = 'nodes')
edges <- tibble(from = search$father, to = seq_len(nrow(nodes)))
edges <- tibble(from = search$parent, to = seq_len(nrow(nodes)))
edges <- edges[!is.na(edges$from), , drop = FALSE]
tbl_graph(nodes, edges)
}
4 changes: 2 additions & 2 deletions R/search.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bfs_parent <- function(root, mode = 'out', unreachable = FALSE) {
graph <- .G()
root <- as_node_ind(root, graph)
ind <- bfs(graph = graph, root = root, mode = mode, unreachable = unreachable,
order = TRUE, father = TRUE)$father
order = TRUE, parent = TRUE)$parent
as.integer(ind)[focus_ind(graph, 'nodes')]
}
#' @describeIn search_graph Get the node that was visited before each node in a breath first search
Expand Down Expand Up @@ -125,7 +125,7 @@ dfs_parent <- function(root, mode = 'out', unreachable = FALSE) {
graph <- .G()
root <- as_node_ind(root, graph)
ind <- dfs(graph = graph, root = root, mode = mode, unreachable = unreachable,
order = TRUE, father = TRUE)$father
order = TRUE, parent = TRUE)$parent
as.integer(ind)[focus_ind(graph, 'nodes')]
}
#' @describeIn search_graph Get the number of nodes between the root and each node in a depth first search
Expand Down
Loading