# Before getting node ID values, create a
# simple graph
nodes <-
create_nodes(
nodes = c("a", "b", "c", "d"),
type = "letter",
color = c("red", "green", "grey", "blue"),
value = c(3.5, 2.6, 9.4, 2.7))
graph <-
create_graph(nodes_df = nodes)
# Get a vector of all nodes in a graph
get_nodes(graph)
#> [1] "a" "b" "c" "d"
# Get a vector of node ID values from a node
# data frame
get_nodes(nodes)
#> [1] "a" "b" "c" "d"
# Get a vector of node ID values using a numeric
# comparison (i.e., all nodes with 'value' attribute
# greater than 3)
get_nodes(
graph,
node_attr = "value",
match = "> 3")
#> [1] "a" "c"
# Get a vector of node ID values using a match
# pattern (i.e., all nodes with 'color' attribute
# of "green")
get_nodes(
graph,
node_attr = "color",
match = "green")
#> [1] "b"
Run the code above in your browser using DataLab