R/simplify_igraph_network.R
simplify_igraph_network.Rd
Simplify an igraph network such that consecutive linear edges are removed
simplify_igraph_network(gr, allow_duplicated_edges = TRUE, allow_self_loops = TRUE, force_keep = NULL, edge_points = NULL)
gr | an igraph object |
---|---|
allow_duplicated_edges | Whether or not to allow duplicated edges between nodes. |
allow_self_loops | Whether or not to allow self loops. |
force_keep | Nodes that will not be removed under any condition |
edge_points | Points that are on edges |
net <- data.frame( from = 1:2, to = 2:3, length = 1, directed = TRUE, stringsAsFactors = F ) gr <- igraph::graph_from_data_frame(net) simplify_igraph_network(gr)#> IGRAPH d87dcf6 DNW- 2 1 -- #> + attr: name (v/c), length (e/n), directed (e/l), weight (e/n) #> + edge from d87dcf6 (vertex names): #> [1] 1->3net <- data.frame( from = c(1, 2, 3, 1), to = c(2, 3, 1, 4), length = 1, directed = TRUE, stringsAsFactors = F ) gr <- igraph::graph_from_data_frame(net) simplify_igraph_network(gr)#> IGRAPH 60d5d0a DNW- 2 2 -- #> + attr: name (v/c), length (e/n), directed (e/l), weight (e/n) #> + edges from 60d5d0a (vertex names): #> [1] 1->4 1->1net <- data.frame( from = c(1, 2, 3, 4), to = c(2, 3, 1, 5), length = 1, directed = TRUE, stringsAsFactors = F ) gr <- igraph::graph_from_data_frame(net) simplify_igraph_network(gr)#> IGRAPH 5c31f2d DNW- 3 2 -- #> + attr: name (v/c), length (e/n), directed (e/l), weight (e/n) #> + edges from 5c31f2d (vertex names): #> [1] 1->1 4->5