powered by
This function removes specified nodes from an event tree, updating edges to maintain the tree structure while ensuring that node IDs remain sequential.
delete_nodes( event_tree_obj, nodes_to_delete, level_separation = 1000, node_distance = 300 )
A list containing:
$eventtree: A visNetwork object representing the updated event tree.
$eventtree
visNetwork
$filtereddf: The filtered data frame, returned invisibly.
$filtereddf
A list containing the event tree object, which includes:
$eventtree$x: A list with nodes and edges data frames.
$eventtree$x
nodes
edges
$filtereddf: The data frame used to create the event tree.
A character vector of node IDs to delete from the event tree.
Numeric value specifying the spacing between levels in the hierarchical layout. Default is 1000.
1000
Numeric value specifying the distance between nodes in the layout. Default is 300.
300
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.
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
Run the code above in your browser using DataLab