# Create a node data frame (ndf)
nodes <-
create_nodes(
nodes = LETTERS)
# Create an edge data frame (edf)
edges <-
create_edges(
from = sample(LETTERS, replace = TRUE),
to = sample(LETTERS, replace = TRUE))
# From the ndf and edf, create a graph object
graph <-
create_graph(
nodes_df = nodes,
edges_df = edges)
# Get predecessors for node `Z` in the graph
get_predecessors(graph, node = "Z")
#> [1] "A" "R" "R"
# If there are no predecessors, NA is returned
get_predecessors(graph, node = "A")
#> [1] NA
Run the code above in your browser using DataLab