I have come across some subtle but dangerous inconsistencies with rigraph functions that take edge or vertex ids as an argument. These functions include induced_subgraph, subgraph.edges, and add_edges. Sometimes a function expects a V(.) or E(.) object; sometimes a vector of named vertices or edges, e.g. as_ids(V(.)) or as_ids(E(.)); and sometimes a function appears to take numeric vertex/edge indices, e.g. which(V(.)$name %in% some_selection. It is generally not clear from the documentation which type of input is expected for a given function, and rigraph usually doesn't fail---rather it just gives different (wrong) results. I've had enough problems with it that I actually switched over to network and sna packages, but my graphs are large enough that performance is an issue (and besides, they are not as versatile).
I will work up a reproducible example soon. I think it is important to enforce some common requirements to rigraph functions that take vertex/edge ids as arguments. I think the best option is to either use the as_ids function in rigraph functions to enforce a consistency, or to have functions always expect a V(.) or E(.) object.
I have come across some subtle but dangerous inconsistencies with
rigraphfunctions that take edge or vertex ids as an argument. These functions includeinduced_subgraph,subgraph.edges, andadd_edges. Sometimes a function expects aV(.)orE(.)object; sometimes a vector of named vertices or edges, e.g.as_ids(V(.))oras_ids(E(.)); and sometimes a function appears to take numeric vertex/edge indices, e.g.which(V(.)$name %in% some_selection. It is generally not clear from the documentation which type of input is expected for a given function, andrigraphusually doesn't fail---rather it just gives different (wrong) results. I've had enough problems with it that I actually switched over tonetworkandsnapackages, but my graphs are large enough that performance is an issue (and besides, they are not as versatile).I will work up a reproducible example soon. I think it is important to enforce some common requirements to
rigraphfunctions that take vertex/edge ids as arguments. I think the best option is to either use theas_idsfunction inrigraphfunctions to enforce a consistency, or to have functions always expect aV(.)orE(.)object.