| Title: | Fast and Efficient Graph Data Structures |
|---|---|
| Description: | Seamlessly build and manipulate graph structures, leveraging its high-performance methods for filtering, joining, and mutating data. Ensures that mutations and changes to the graph are performed in place, streamlining your workflow for optimal productivity. |
| Authors: | ixpantia, SRL [cph], Andres Quintero [aut, cre], The authors of the dependency Rust crates [ctb] (see inst/AUTHORS file for details) |
| Maintainer: | Andres Quintero <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.18.2 |
| Built: | 2026-05-12 08:26:30 UTC |
| Source: | https://github.com/ixpantia/orbweaver-r |
Adds an edge from one node to another in a a directed graph builder.
add_edge(graph_builder, from, to)add_edge(graph_builder, from, to)
graph_builder |
A graph builder_object |
from |
The |
to |
The |
The updated graph builder object
Other build graphs:
add_path(),
build_acyclic(),
build_directed(),
graph_builder(),
populate_edges()
graph_builder() |> add_edge("A", "B")graph_builder() |> add_edge("A", "B")
Adds all of the edges that make up the given path to the graph.
add_path(graph_builder, path)add_path(graph_builder, path)
graph_builder |
A graph builder_object |
path |
A character vector that describes the path |
The updated graph builder object
Other build graphs:
add_edge(),
build_acyclic(),
build_directed(),
graph_builder(),
populate_edges()
graph_builder() |> add_path(c("A", "B", "C"))graph_builder() |> add_path(c("A", "B", "C"))
Builds a graph builder into a new DirectedAcyclicGraph object.
NOTE: This will consume the builder. It will leave an empty builder in its place.
build_acyclic(graph_builder)build_acyclic(graph_builder)
graph_builder |
A graph builder object |
A DirectedAcyclicGraph Object
Other build graphs:
add_edge(),
add_path(),
build_directed(),
graph_builder(),
populate_edges()
graph_builder() |> add_path(c("1", "2", "3", "4")) |> build_acyclic()graph_builder() |> add_path(c("1", "2", "3", "4")) |> build_acyclic()
Builds a graph builder into a new DirectedGraph object.
NOTE: This will consume the builder. It will leave an empty builder in its place.
build_directed(graph_builder)build_directed(graph_builder)
graph_builder |
A graph builder object |
A DirectedGraph Object
Other build graphs:
add_edge(),
add_path(),
build_acyclic(),
graph_builder(),
populate_edges()
graph_builder() |> add_path(c("1", "2", "3", "4")) |> build_directed()graph_builder() |> add_path(c("1", "2", "3", "4")) |> build_directed()
Get a list of the node ids of the children of the provided node.
children(graph, nodes)children(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to find children for |
A character vector
graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph |> children("A")graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph |> children("A")
Find all the paths between two nodes in a graph.
Not all graphs support this function. Currently only
DirectedAcyclicGraph supports this.
find_all_paths(graph, from, to)find_all_paths(graph, from, to)
graph |
A graph object |
from |
The starting node of the path |
to |
The ending node of the path |
A list of character vectors
Other analyze graphs:
find_path(),
find_path_one_to_many(),
get_all_leaves(),
get_all_roots(),
get_leaves_under(),
get_roots_over(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "Z", "C")) |> add_path(c("A", "B", "A")) |> build_directed() find_all_paths(graph, "A", "C")graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "Z", "C")) |> add_path(c("A", "B", "A")) |> build_directed() find_all_paths(graph, "A", "C")
Finds a path between two nodes in a graph.
Different types of graphs use different algorithms to
find the paths. a DirectedGraph uses breadth-first search
while an DirectedAcyclicGraph uses topological sort.
The path is represented as a character vector with the node ids of the nodes that make up the path.
find_path(graph, from, to)find_path(graph, from, to)
graph |
A graph object |
from |
The starting node of the path |
to |
The ending node of the path |
A character vector
Other analyze graphs:
find_all_paths(),
find_path_one_to_many(),
get_all_leaves(),
get_all_roots(),
get_leaves_under(),
get_roots_over(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> build_directed() find_path(graph, "A", "C")graph <- graph_builder() |> add_path(c("A", "B", "C")) |> build_directed() find_path(graph, "A", "C")
Find a valid path from one node to many
find_path_one_to_many(graph, from, to)find_path_one_to_many(graph, from, to)
graph |
A graph object |
from |
The starting node of the path |
to |
A character vector of nodes |
A list of paths
Other analyze graphs:
find_all_paths(),
find_path(),
get_all_leaves(),
get_all_roots(),
get_leaves_under(),
get_roots_over(),
least_common_parents()
edges <- data.frame( parent = c("A", "A", "B", "Z"), child = c("B", "Z", "Z", "F") ) graph <- graph_builder() |> populate_edges(edges, parent, child) |> build_acyclic() find_path_one_to_many(graph, "A", edges$child)edges <- data.frame( parent = c("A", "A", "B", "Z"), child = c("B", "Z", "Z", "F") ) graph <- graph_builder() |> populate_edges(edges, parent, child) |> build_acyclic() find_path_one_to_many(graph, "A", edges$child)
Retrieves the nodes in a graph that have no children
get_all_leaves(graph, ...)get_all_leaves(graph, ...)
graph |
A graph object |
... |
Unused |
A character vector of nodes
Other analyze graphs:
find_all_paths(),
find_path(),
find_path_one_to_many(),
get_all_roots(),
get_leaves_under(),
get_roots_over(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> add_path(c("Z", "B", "H")) |> build_directed() get_all_leaves(graph)graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> add_path(c("Z", "B", "H")) |> build_directed() get_all_leaves(graph)
Retrieves the nodes in a graph that have no parents
get_all_roots(graph, ...)get_all_roots(graph, ...)
graph |
A graph object |
... |
Unused |
A character vector of nodes
Other analyze graphs:
find_all_paths(),
find_path(),
find_path_one_to_many(),
get_all_leaves(),
get_leaves_under(),
get_roots_over(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> build_directed() get_all_roots(graph)graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> build_directed() get_all_roots(graph)
Get leaves of a set of nodes in a data frame format.
get_leaves_as_df(graph, nodes)get_leaves_as_df(graph, nodes)
graph |
A graph object |
nodes |
A character vector of node IDs |
A data frame of leaves
Retrieves the nodes in a graph that have no children under a certain node or group of nodes
get_leaves_under(graph, nodes)get_leaves_under(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to find leaves for |
A character vector of nodes
Other analyze graphs:
find_all_paths(),
find_path(),
find_path_one_to_many(),
get_all_leaves(),
get_all_roots(),
get_roots_over(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> add_path(c("Z", "B", "H")) |> build_directed() get_leaves_under(graph, "D")graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> add_path(c("Z", "B", "H")) |> build_directed() get_leaves_under(graph, "D")
Retrieves the nodes in a graph that have no parents over a certain node or group of nodes
get_roots_over(graph, nodes)get_roots_over(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to find roots for |
A character vector of nodes
Other analyze graphs:
find_all_paths(),
find_path(),
find_path_one_to_many(),
get_all_leaves(),
get_all_roots(),
get_leaves_under(),
least_common_parents()
graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> build_directed() get_roots_over(graph, "D")graph <- graph_builder() |> add_path(c("A", "B", "C")) |> add_path(c("A", "D", "C")) |> add_path(c("Z", "B", "C")) |> build_directed() get_roots_over(graph, "D")
Object used to build graphs
graph_builder(type = c("directed"))graph_builder(type = c("directed"))
type |
The type of graph |
An object of class 'DirectedGraphBuilder'.
Other build graphs:
add_edge(),
add_path(),
build_acyclic(),
build_directed(),
populate_edges()
graph_builder()graph_builder()
Read the graph from a binary blob
graph_from_bin(path, bin, type = c("directed", "dag"))graph_from_bin(path, bin, type = c("directed", "dag"))
path |
(Optional) Path to a file containing a graph binary |
bin |
(Optional) The raw binary of the graph |
type |
The type of graph the JSON represents |
A graph object
Other graphs i/o:
graph_to_bin()
bin <- graph_builder() |> add_edge("A", "B") |> build_directed() |> graph_to_bin() bin graph_from_bin(bin = bin)bin <- graph_builder() |> add_edge("A", "B") |> build_directed() |> graph_to_bin() bin graph_from_bin(bin = bin)
Save the graph into a binary blob
graph_to_bin(graph, path)graph_to_bin(graph, path)
graph |
A graph object |
path |
Path to a file to save the graph into |
Run for its side-effects
Other graphs i/o:
graph_from_bin()
graph <- graph_builder() |> add_edge("A", "B") |> build_directed() graph_to_bin(graph)graph <- graph_builder() |> add_edge("A", "B") |> build_directed() graph_to_bin(graph)
This function validates if the node has an edge pointing to any other node.
has_children(graph, nodes)has_children(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to determine |
A logical vector with the same length as nodes
graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph graph |> has_children(nodes = "A") graph |> has_children(nodes = "B")graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph graph |> has_children(nodes = "A") graph |> has_children(nodes = "B")
This function validates if any edge points to the given node.
has_parents(graph, nodes)has_parents(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to determine |
A logical vector with the same length as nodes
graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph graph |> has_parents(nodes = "A") graph |> has_parents(nodes = "B")graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph graph |> has_parents(nodes = "A") graph |> has_parents(nodes = "B")
It finds the nodes that have no parents in the given set.
least_common_parents(graph, selected)least_common_parents(graph, selected)
graph |
A graph object |
selected |
A character vector of node ids |
A character vector of node ids
Other analyze graphs:
find_all_paths(),
find_path(),
find_path_one_to_many(),
get_all_leaves(),
get_all_roots(),
get_leaves_under(),
get_roots_over()
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 graph |> least_common_parents(c("D", "E"))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 graph |> least_common_parents(c("D", "E"))
Returns the unique nodes in the graph
nodes(graph, ...)nodes(graph, ...)
graph |
A directed or directed acyclic graph |
... |
Reserved for later use |
A character vector with the nodes
graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph nodes(graph)graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph nodes(graph)
Get a list of the node ids of the parents of the provided node.
parents(graph, nodes)parents(graph, nodes)
graph |
A graph object |
nodes |
A character vector of nodes to find parents for |
A character vector
graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph |> parents("A") graph |> parents("B")graph <- graph_builder() |> add_edge(from = "A", to = "B") |> build_directed() graph |> parents("A") graph |> parents("B")
data.frame
Adds a set of edges from a data.frame to a graph
populate_edges(graph_builder, edges_df, parent_col, child_col)populate_edges(graph_builder, edges_df, parent_col, child_col)
graph_builder |
A graph builder object |
edges_df |
A |
parent_col |
The name of the column containing the parents |
child_col |
The name of the column containing the children |
The updated graph builder object
Other build graphs:
add_edge(),
add_path(),
build_acyclic(),
build_directed(),
graph_builder()
graph_edges <- data.frame( parent = c("A", "B", "C"), child = c("B", "C", "D") ) graph_builder() |> populate_edges( edges_df = graph_edges, parent_col = "parent", child_col = "child" )graph_edges <- data.frame( parent = c("A", "B", "C"), child = c("B", "C", "D") ) graph_builder() |> populate_edges( edges_df = graph_edges, parent_col = "parent", child_col = "child" )