find_path: Find a path between two nodes

View source: R/find_path.R View source: R/extendr-wrappers.R View source: R/extendr-wrappers.R

find_pathR Documentation

Find a path between two nodes

Description

Finds a path between two nodes in a graph.

Different types of graphs use different algorithms to find the paths. a DirectedGraph uses breadth-first search while an DirectedAcyclicGraph uses topological sort.

The path is represented as a character vector with the node ids of the nodes that make up the path.

Usage

find_path(graph, from, to)

Arguments

graph

A graph object

from

The starting node of the path

to

The ending node of the path

Value

A character vector

See Also

Other analyze graphs: find_all_paths(), find_path_one_to_many(), get_all_leaves(), get_all_roots(), get_leaves_under(), get_roots_over(), least_common_parents()

Examples

graph <- graph_builder() |>
  add_path(c("A", "B", "C")) |>
  build_directed()

find_path(graph, "A", "C")

orbweaver documentation built on June 8, 2025, 11:40 a.m.