delete_nodes {stCEG} | R Documentation |
Delete Nodes from an Event Tree
Description
This function removes specified nodes from an event tree, updating edges to maintain the tree structure while ensuring that node IDs remain sequential.
Usage
delete_nodes(
event_tree_obj,
nodes_to_delete,
level_separation = 1000,
node_distance = 300
)
Arguments
event_tree_obj |
A list containing the event tree object, which includes:
|
nodes_to_delete |
A character vector of node IDs to delete from the event tree. |
level_separation |
Numeric value specifying the spacing between levels in the hierarchical layout.
Default is |
node_distance |
Numeric value specifying the distance between nodes in the layout.
Default is |
Details
The function performs the following steps:
Identifies outgoing and incoming edges for each node marked for deletion.
Redirects outgoing edges to the sources of the incoming edges.
Updates the edges and nodes data frames to reflect the new connections.
Ensures node IDs are sequentially re-assigned.
Adjusts outgoing edge counts for affected nodes.
Removes orphaned nodes (nodes with no connections).
Returns an updated
visNetwork
visualization of the event tree.
Value
A list containing:
-
$eventtree
: AvisNetwork
object representing the updated event tree. -
$filtereddf
: The filtered data frame, returned invisibly.
Examples
data <- homicides
event_tree <- create_event_tree(data, columns = c(1,2,4,5), "both")
event_tree
updated_tree <- delete_nodes(event_tree, nodes_to_delete = c("s14", "s18"))
updated_tree