Skip to contents

It finds the nodes that have no parents in the given set.

Usage

least_common_parents(graph, selected)

Arguments

graph

A graph object

selected

A character vector of node ids

Value

A character vector of node ids

Examples

graph_edges <- data.frame(
  parent = c("A", "B", "C", "C", "F"),
  child = c("B", "C", "D", "E", "D")
)

graph <- graph_builder() |>
  populate_edges(graph_edges, parent, child) |>
  build_directed()
graph
#> # of nodes: 6
#> # of edges: 5
#> # of roots: 2
#> # of leaves: 2
#> 
#> |     Parent      |      Child      |
#> | --------------- | --------------- |
#> | A               | B               |
#> | B               | C               |
#> | C               | E               |
#> | C               | D               |
#> | F               | D               |
#> 

graph |> least_common_parents(c("D", "E"))
#> # of nodes: 2
#> |           Nodes           |
#> |             D             |
#> |             E             |
#>