Function reference
External NDF/EDF
These functions create external node data frames (NDFs) and external edge data frames (EDFs). These specialized tables can be used to create graphs.

create_node_df()
 Create a node data frame

create_edge_df()
 Create an edge data frame

combine_ndfs()
 Combine multiple node data frames

combine_edfs()
 Combine multiple edge data frames into a single edge data frame
Graph Creation, Rendering, and I/O
Graphs can be created, read in, written out, and displayed with these functions.

create_graph()
 Create a graph object

import_graph()
 Import a graph from various graph formats

from_adj_matrix()
 Create a graph using an adjacency matrix

from_igraph()
 Convert an igraph graph to a DiagrammeR one

to_igraph()
 Convert a DiagrammeR graph to an igraph one

open_graph()
 Read a graph or graph series from disk

save_graph()
 Save a graph or graph series to disk

export_graph()
 Export a graph to various image formats

export_csv()
 Export a graph to CSV files

render_graph()
 Render the graph in various formats

display_metagraph()
 Display a property graph's underlying model
Node and Edge Selection
Graph nodes or edges can be selected with these functions. This is useful because some of the Graph Modification functions (ending with “_ws”) and all of the Graph Traversal functions can make use of the stored selections.

select_nodes()
 Select nodes in a graph

select_nodes_by_id()
 Select nodes in a graph by their ID values

select_nodes_by_degree()
 Select nodes in the graph based on their degree values

select_nodes_in_neighborhood()
 Select nodes based on a walk distance from a specified node

select_last_nodes_created()
 Select the last set of nodes created in a graph

select_edges()
 Select edges in a graph

select_edges_by_node_id()
 Select edges in a graph using node ID values

select_edges_by_edge_id()
 Select edges in a graph using edge ID values

select_last_edges_created()
 Select the last set of edges created in a graph

get_selection()
 Get the current selection available in a graph object

deselect_nodes()
 Deselect any selected nodes in a graph

deselect_edges()
 Deselect any selected edges in a graph

invert_selection()
 Invert selection of nodes or edges in a graph

clear_selection()
 Clear an active selection of nodes or edges
Graph Modification
These functions make changes to the graph. We can change many aspects of the graph: the graph representation itself (e.g., adding or removing nodes and edges), or, the attributes of the nodes and edges (in terms of associated data and aesthetics).

add_node()
 Add a node to an existing graph object

add_n_nodes()
 Add one or several unconnected nodes to the graph

add_n_nodes_ws()
 Add a multiple of new nodes with edges to or from one or more selected nodes

add_node_df()
 Add nodes from a node data frame to an existing graph object

add_n_node_clones()
 Add one or several clones of an existing node to the graph

add_node_clones_ws()
 Add clones of a selection of nodes

add_nodes_from_table()
 Add nodes and attributes to graph from a table

add_nodes_from_df_cols()
 Add nodes from distinct values in data frame columns

add_edge()
 Add an edge between nodes in a graph object

add_edge_df()
 Add edges from an edge data frame to an existing graph object

add_edges_w_string()
 Add one or more edges using a text string

add_edge_clone()
 Add a clone of an existing edge to the graph

add_forward_edges_ws()
 Add new edges with identical definitions as with a selection of edges

add_reverse_edges_ws()
 Add new edges in the opposite directions of a selection of edges

fully_connect_nodes_ws()
 Fully connect all nodes in a selection of nodes

add_edges_from_table()
 Add edges and attributes to graph from a table

add_path()
 Add a path of nodes to the graph

add_cycle()
 Add a cycle of nodes to the graph

add_balanced_tree()
 Add a balanced tree to the graph

add_star()
 Add a star of nodes to the graph

add_prism()
 Add a prism of nodes to the graph

add_full_graph()
 Add a fully connected graph

add_grid_2d()
 Add a 2D grid of nodes to the graph

add_grid_3d()
 Add a 3D grid of nodes to the graph

add_gnm_graph()
 Add a G(n, m) ErdosRenyi graph

add_gnp_graph()
 Add a G(n, p) ErdosRenyi graph

add_pa_graph()
 Add a preferential attachment graph

add_growing_graph()
 Create a random growing graph with m edges added per step

add_smallworld_graph()
 Add a WattsStrogatz smallworld graph

add_islands_graph()
 Create a random islands graph with edges between the islands

delete_node()
 Delete a node from an existing graph object

delete_nodes_ws()
 Delete all nodes in a node selection

delete_edge()
 Delete an edge from an existing graph object

delete_edges_ws()
 Delete all selected edges in an edge selection

delete_loop_edges_ws()
 Delete all loop edges associated with a selection of nodes

fully_disconnect_nodes_ws()
 Fully disconnect all nodes in a selection of nodes

rev_edge_dir()
 Reverse the direction of all edges in a graph

rev_edge_dir_ws()
 Reverse the direction of selected edges in a graph using an edge selection

set_node_attrs()
 Set node attribute values

set_node_attrs_ws()
 Set node attributes with a node selection

join_node_attrs()
 Join new node attribute values using a data frame

rescale_node_attrs()
 Rescale numeric node attribute values

copy_node_attrs()
 Copy a node attribute column and set the name

rename_node_attrs()
 Rename a node attribute

drop_node_attrs()
 Drop a node attribute column

mutate_node_attrs()
 Mutate a set of node attribute values

mutate_node_attrs_ws()
 Mutate node attribute values for a selection of nodes

colorize_node_attrs()
 Apply colors based on node attribute values

recode_node_attrs()
 Recode a set of node attribute values

set_node_position()
 Apply a layout position to a single node

layout_nodes_w_string()
 Layout nodes using a textbased schematic

nudge_node_positions_ws()
 Move layout positions of a selection of nodes

set_node_attr_w_fcn()
 Set node attribute values with a graph function

set_edge_attrs()
 Set edge attribute values

set_edge_attrs_ws()
 Set edge attributes with an edge selection

join_edge_attrs()
 Join new edge attribute values using a data frame

rescale_edge_attrs()
 Rescale numeric edge attribute values

copy_edge_attrs()
 Copy an edge attribute column and set the name

rename_edge_attrs()
 Rename an edge attribute

drop_edge_attrs()
 Drop an edge attribute column

mutate_edge_attrs()
 Mutate a set of edge attribute values

mutate_edge_attrs_ws()
 Mutate edge attribute values for a selection of edges

colorize_edge_attrs()
 Apply colors based on edge attribute values

recode_edge_attrs()
 Recode a set of edge attribute values

node_data()
 Insert node data attributes during node creation

node_aes()
 Insert node aesthetic attributes during node creation

edge_data()
 Insert edge data attributes during edge creation

edge_aes()
 Insert edge aesthetic attributes during edge creation
Graph Transformation
Wholesale changes to a graph can be made with any of these functions. Combine two graphs, transform them to different representations, even change whether the graph is directed or undirected.

combine_graphs()
 Combine two graphs into a single graph

transform_to_subgraph_ws()
 Create a subgraph using a node or edge selection

transform_to_complement_graph()
 Create a complement of a graph

transform_to_min_spanning_tree()
 Get a minimum spanning tree subgraph

set_graph_undirected()
 Convert a directed graph to an undirected graph

set_graph_directed()
 Convert an undirected graph to a directed graph
Graph Inspection
Sometimes, you’ll need to gather information about the working graph. This collection of functions allows for extraction of graph components (e.g., ndfs and edfs), attribute information, counts, node and edge properties, and more.

get_node_df()
 Get a node data frame from a graph

get_node_df_ws()
 Get the graph's ndf filtered by a selection of nodes

get_node_info()
 Get detailed information on nodes

get_last_nodes_created()
 Get the last set of nodes created in a graph

get_node_attrs()
 Get node attribute values

get_node_attrs_ws()
 Get node attribute values from a selection of nodes

get_degree_distribution()
 Get total degree distribution data for a graph

get_degree_histogram()
 Get histogram data for a graph's degree frequency

get_edge_df()
 Get an edge data frame from a graph

get_edge_df_ws()
 Get the graph's edf filtered by a selection of edges

get_edge_info()
 Get detailed information on edges

get_last_edges_created()
 Get the last set of edges created in a graph

get_edge_attrs()
 Get edge attribute values

get_edge_attrs_ws()
 Get edge attribute values from a selection of edges

get_node_ids()
 Get a vector of node ID values

get_nbrs()
 Get all neighbors of one or more nodes

get_common_nbrs()
 Get all common neighbors between two or more nodes

get_non_nbrs()
 Get nonneighbors of a node in a graph

get_similar_nbrs()
 Get neighboring nodes based on node attribute similarity

get_predecessors()
 Get node IDs for predecessor nodes to the specified node

get_successors()
 Get node IDs for successor nodes to the specified node

get_all_connected_nodes()
 Get all nodes connected to a specified node

get_articulation_points()
 Get articulation points

get_periphery()
 Get nodes that form the graph periphery

get_edge_ids()
 Get a vector of edge ID values

get_edges()
 Get node IDs associated with edges

get_paths()
 Get paths from a specified node in a directed graph

get_graph_info()
 Get metrics for a graph

do_dfs()
 Use the depthfirst search (dfs) algorithm

do_bfs()
 Use the breadthfirst search (bfs) algorithm

count_nodes()
 Get a count of all nodes

count_edges()
 Get a count of all edges

count_loop_edges()
 Get count of all loop edges

count_mutual_node_pairs()
 Get the number of mutuallyconnected node pairs

count_asymmetric_node_pairs()
 Get the number of asymmetricallyconnected node pairs

count_automorphisms()
 Get the number of automorphisms

count_unconnected_nodes()
 Get count of all unconnected nodes

count_unconnected_node_pairs()
 Get the number of unconnected node pairs

count_w_connected_cmpts()
 Get the number of weaklyconnected components

count_s_connected_cmpts()
 Get the number of stronglyconnected components

get_multiedge_count()
 Get the count of multiple edges

get_edge_count_w_multiedge()
 Get count of edge definitions where multiple edges occur

get_agg_degree_in()
 Get an aggregate value from the indegree of nodes

get_agg_degree_out()
 Get an aggregate value from the outdegree of nodes

get_agg_degree_total()
 Get an aggregate value from the total degree of nodes

get_mean_distance()
 Get the mean distance

get_min_eccentricity()
 Get the minimum graph eccentricity

get_max_eccentricity()
 Get the maximum graph eccentricity

get_reciprocity()
 Get the graph reciprocity

get_girth()
 Get the graph girth

get_adhesion()
 Get graph adhesion

get_min_cut_between()
 Get the minimum cut between source and sink nodes

get_degree_in()
 Get indegree values for all nodes

get_degree_out()
 Get outdegree values for all nodes

get_degree_total()
 Get total degree values for all nodes

get_betweenness()
 Get betweenness centrality scores

get_closeness()
 Get closeness centrality values

get_pagerank()
 Get the PageRank values for all nodes

get_alpha_centrality()
 Get the alpha centrality for all nodes

get_eigen_centrality()
 Get the eigen centrality for all nodes

get_authority_centrality()
 Get the authority scores for all nodes

get_leverage_centrality()
 Get leverage centrality

get_radiality()
 Get radiality centrality scores

get_eccentricity()
 Get node eccentricities

get_coreness()
 Get coreness values for graph nodes

get_closeness_vitality()
 Get closeness vitality

get_dice_similarity()
 Get Dice similarity coefficient scores

get_jaccard_similarity()
 Get Jaccard similarity coefficient scores

get_w_connected_cmpts()
 Get all nodes associated with connected components

get_s_connected_cmpts()
 Get nodes within strongly connected components

get_cmty_edge_btwns()
 Get community membership by edge betweenness

get_cmty_walktrap()
 Get community membership using the Walktrap method

get_cmty_louvain()
 Get community membership by Louvain optimization

get_cmty_l_eigenvec()
 Get community membership by leading eigenvector

get_cmty_fast_greedy()
 Get community membership by modularity optimization

is_node_present()
 Determine whether a specified node is present

is_edge_present()
 Determine whether a specified edge is present

is_edge_loop()
 Is the edge a loop edge?

is_edge_multiple()
 Is the edge a multiple edge?

is_edge_mutual()
 Is the edge mutual with another edge?

is_graph_empty()
 Is the graph empty?

is_graph_directed()
 Is the graph a directed graph?

is_graph_undirected()
 Is the graph an undirected graph?

is_graph_simple()
 Is the graph a simple graph?

is_graph_weighted()
 Is the graph a weighted graph?

is_graph_connected()
 Is the graph a connected graph?

is_graph_dag()
 Is the graph a directed acyclic graph?

is_property_graph()
 Is the graph a property graph?
Value Caching
Think of caching as a way to temporarily store a vector of values within the graph. Why do this? Well, one could extract node or edge data as vector, cache that in the graph, and then later use it as input in another function, all in the same functional pipeline.

set_cache()
 Cache a vector in the graph

get_cache()
 Get a cached vector from a graph object

delete_cache()
 Delete vectors cached in a graph object
Graph Traversal
Traversing the graph is useful if you have a defined graph model and you’d like to explore the connections and relationships between nodes and edges. Traversals effectively modify a selection of nodes or edges. With the modified selection, we can extract related attributes and work with them.

trav_out()
 Traverse from one or more selected nodes onto adjacent, outward nodes

trav_in()
 Traverse from one or more selected nodes onto adjacent, inward nodes

trav_both()
 Traverse from one or more selected nodes onto neighboring nodes

trav_out_edge()
 Traverse from one or more selected nodes onto adjacent, outward edges

trav_in_edge()
 Traverse from one or more selected nodes onto adjacent, inward edges

trav_both_edge()
 Traverse from one or more selected nodes onto adjacent edges

trav_out_node()
 Traverse from one or more selected edges onto adjacent, outward nodes

trav_in_node()
 Traverse from one or more selected edges onto adjacent, inward nodes

trav_out_until()
 Traverse outward nodebynode until stopping conditions are met

trav_in_until()
 Traverse inward nodebynode until stopping conditions are met

trav_reverse_edge()
 Traverse to any reverse edges
Graph Series
A series of graphs can be occasionally useful. It’s a convenient container for a set of closely related graphs (for example, a network that changes with time).

create_graph_series()
 Create a graph series object

add_graph_to_graph_series()
 Add graph object to a graph series object

remove_graph_from_graph_series()
 Remove a graph from a graph series

filter_graph_series()
 Subset a graph series object

count_graphs_in_graph_series()
 Count graphs in a graph series object

get_graph_from_graph_series()
 Get a graph available in a series

get_graph_series_info()
 Get information on a graph series

render_graph_from_graph_series()
 Render a graph available in a series
Graph Metadata
Graph metadata consist of the attributes that don’t necessarily belong to the individual nodes or edges, but, may affect their appearance when the graph is rendered. These metadata can also apply directly to the graph object itself.

add_global_graph_attrs()
 Add one or more global graph attributes

delete_global_graph_attrs()
 Delete one of the global graph attributes stored within a graph object

get_global_graph_attr_info()
 Get global graph attributes

set_graph_name()
 Set graph name

set_graph_time()
 Set graph datetime and timezone

set_node_attr_to_display()
 Set the node attribute values to be rendered

set_edge_attr_to_display()
 Set the edge attribute values to be rendered

get_graph_name()
 Get graph name

get_graph_time()
 Get the graph datetime or timezone

get_graph_log()
 Get the graph log information
Graph Actions
Take action! Think of graph actions as little subroutines that execute at every meaningful change of the graph.

add_graph_action()
 Add a graph action for execution at every transform

delete_graph_actions()
 Delete one or more graph actions stored within a graph object

get_graph_actions()
 Get information on any available graph actions

reorder_graph_actions()
 Reorder the stored series of graph actions

trigger_graph_actions()
 Trigger the execution of a series of graph actions

DiagrammeR()
 R + mermaid.js

grViz()
 R + viz.js

generate_dot()
 Generate DOT code using a graph object

replace_in_spec()
 Razorlike template for diagram specification

mermaid()
 R + mermaid.js

visnetwork()
 Render graph with visNetwork

renderDiagrammeR()
 Widget render function for use in Shiny

DiagrammeROutput()
 Widget output function for use in Shiny

renderGrViz()
 Widget render function for use in Shiny

grVizOutput()
 Widget output function for use in Shiny

node_list_1
 Node list  Version 1.

edge_list_1
 Edge list  Version 1.

node_list_2
 Node list  Version 2.

edge_list_2
 Edge list  Version 2.

currencies
 ISO4217 currency data.

usd_exchange_rates
 US Dollar exchange rates.