Learn R Programming

DiagrammeR (version 0.7)

is_graph_empty: Is the graph empty?

Description

Determines whether a graph contains any nodes and returns a logical value to reflect emptiness.

Usage

is_graph_empty(graph)

Arguments

graph
a graph object of class dgr_graph.

Value

  • a logical value.

Examples

Run this code
# Create an empty graph
graph <- create_graph()

# Determine whether the graph is empty
is_graph_empty(graph)
#> [1] TRUE

# Create a graph with nodes and edges
nodes <-
  create_nodes(nodes = c("a", "b", "c", "d"))

edges <-
  create_edges(from = c("a", "b", "c"),
               to = c("d", "c", "a"))

graph <-
  create_graph(nodes_df = nodes,
               edges_df = edges)

# Determine whether the graph is empty
is_graph_empty(graph)
#> [1] FALSE

Run the code above in your browser using DataLab