# NOT RUN {
# Create a graph with 5 nodes
graph <-
create_graph() %>%
add_path(n = 5)
# Create a graph selection by selecting
# edges with edge IDs `1` and `2`
graph <-
graph %>%
select_edges_by_edge_id(
edges = 1:2)
# Get the selection of edges
graph %>%
get_selection()
#> [1] 1 2
# Perform another selection of edges,
# with edge IDs `1`, `2`, and `4`
graph <-
graph %>%
clear_selection() %>%
select_edges_by_edge_id(
edges = c(1, 2, 4))
# Get the selection of edges
graph %>%
get_selection()
#> [1] 1 2 4
# Get the fraction of edges selected
# over all the edges in the graph
graph %>%
{
l <- get_selection(.) %>%
length(.)
e <- edge_count(.)
l/e
}
#> [1] 0.75
# }
Run the code above in your browser using DataLab