sort_into_components | R Documentation |
This function sorts a set of edges into separate connected components. Each component represents a distinct outline or polygon in the form of connected edges.
sort_into_components(edges_df)
edges_df |
A data frame representing edges, with columns:
(E.g. the output of |
The function identifies unique connected components in an undirected graph built from the edges. It first creates unique identifiers for the start and end points of each edge and constructs an undirected graph using these points. Connected components are then determined, and each component is assigned to a separate element in the output list.
A named list of data frames, where each data frame contains the edges belonging to a separate connected component. The names of the list elements are "c1", "c2", etc., representing each unique component.
# Sample data frame of edges
edges_df <- data.frame(
x1 = c(0, 1, 2, 3),
y1 = c(0, 1, 2, 3),
x2 = c(1, 2, 3, 0),
y2 = c(1, 2, 3, 0)
)
sort_into_components(edges_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.