luukvdmeer / sfnetworks

Tidy Geospatial Networks in R

Home Page:https://luukvdmeer.github.io/sfnetworks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test of directedness could happen outside the find_edges function

Anaphory opened this issue · comments

Currently, the lapply in

new_edge_list = lapply(x_pseudo, find_edges)

calls a function which in every call – i.e. for every subgraph (at least not for every edge, as I originally thought) – tests whether the graph is directed or not:

sfnetworks/R/morphers.R

Lines 583 to 589 in 906f423

find_edges = function(G) {
# Retrieve the original node indices of the pseudo nodes in this set.
# Retrieve the original edge indices of the edges that connect them.
N = vertex_attr(G, ".tidygraph_node_index")
E = edge_attr(G, ".tidygraph_edge_index")
# Find all required node and edge indices.
if (directed) {

Would it not make sense to define find_edges differently for directed and undirected graphs, ie. essentially swapping lines 583 and 589 (with a copy of line 583 in the else, between 625 and 626)?

Fixed in v0.6.0