[WIP] Fix functions ignoring return.vs.es option #2439
                
     Draft
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Fix return.vs.es option handling in multiple functions
This PR fixes several functions that ignore the
return.vs.esoption and always returnigraph.vsorigraph.esobjects even whenreturn.vs.es = FALSE.Plan
head_of()to respectreturn.vs.esoptiontail_of()to respectreturn.vs.esoptionas_adj_edge_list()to respectreturn.vs.esoptiongraph.get.isomorphisms.vf2()to respectreturn.vs.esoptiongraph.get.subisomorphisms.vf2()to respectreturn.vs.esoptiongraph.subisomorphic.lad()to respectreturn.vs.esoptionOriginal prompt
This section details on the original issue you should resolve
<issue_title>Some functions that return vertex or edge sequences ignore the value of the option
return.vs.es</issue_title><issue_description>### What happens, and what did you expect instead?
Several function that return vertex or edge sequences ignore the value of the option
return.vs.esand returnigraph.vsorigraph.esobjects even ifreturn.vs.es = FALSE. A few examples are demonstrated below.I used two regex pattern to search of code that converts numeric indices to
igraph.vsorigraph.esobjects, respectively:"create_(v|e)s"finds uses ofcreate_vs()andcreate_es()(also when they are used insidelapply()etc.)."(E|V)\([^)]\)\["finds constructs of the formE(graph)[i + 1]Most uses of those patterns are already combined with a check for the value of
return.vs.es, but there are a few exceptions:head_of()tail_of()as_adj_edge_list()graph.get.isomorphisms.vf2()graph.get.subisomorphisms.vf2()graph.subisomorphic.lad()I would expect that these functions return (lists of) numeric indices if
return.vs.es = FALSE.To reproduce
Created on 2024-12-02 with reprex v2.1.1
System information
R version 4.4.2 (2024-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=de_CH.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=de_CH.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=de_CH.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Zurich
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_2.1.2
loaded via a namespace (and not attached):
[1] compiler_4.4.2 magrittr_2.0.3 cli_3.6.3 tools_4.4.2 rstudioapi_0.17.1
[6] lifecycle_1.0.4 pkgconfig_2.0.3 rlang_1.1.4</issue_description>
Comments on the Issue (you are @copilot in this section)
@maelle Thank you @stibu81 for the report!@szhorvat any opinion?</comment_new>
<comment_new>@szhorvat
I agree with the principle of updating these functions to respect
return.vs.es, but keep in mind that I rarely use R so there might be problematic consequences I am not thinking of.I'd give these three an extra careful look:
I think this is ultimately an R programming / API decision that should be made by you and @krlmlr.
@krlmlr Agree that we want to be consistent here, but `return.vs.es` is something we may want to get rid of in the medium term. ...return.vs.es#1614💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.