-
-
Notifications
You must be signed in to change notification settings - Fork 206
Use native igraph object as ground truth #787
Copy link
Copy link
Closed
Milestone
Description
Converting from R to C
- No work needs to be done, the native igraph object is stored as an external pointer in the
igraph_t_idx_envpart of the data structure. - When the R graph object is destroyed, it will be garbage-collected eventually. This triggers the finalizer of the external pointer object, which can be made to call destructors in igraph/C.
Converting from C to R
- We keep the native
igraph_tobject and store it as an external pointer in theigraph_t_idx_envpart of the data structure. - We also keep all the information needed to recreate the native
igraph_tobject in theigraph_t_idx_n,igraph_t_idx_directed,igraph_t_idx_fromandigraph_t_idx_tocomponents - The native
igraph_tobject may be lost, e.g., during serialization. In this case, we recreate the nativeigraph_tobject from theigraph_t_idx_n,igraph_t_idx_directed,igraph_t_idx_fromandigraph_t_idx_tocomponents
Attributes
All attributes are still handled only from R for now. But because the native igraph_t object may cache R-level attributes, we need to be especially careful about this.
Implementation steps
- Ensure that all indices into
unclass(g)useigraph_t_idx_*, no magic numbers (chore: Ensure we're always using named indexes to access the internal data structure #784) - Fix problems in fix: revdepcheck results #789
- This PR contains the results from checking all reverse dependencies against 6222e73. This is the commit where all indexes in the internal list have been shifted. It seems like our code (or perhaps even other packages) are relying on those indexes. We need to understand what causes the failures, and fix them.
- Implement accessors (getters + setters) for
igraph_t_idx_n,igraph_t_idx_directed,igraph_t_idx_fromandigraph_t_idx_toin C - Don't use
igraph_t_idx_*from R, at all (we can keep usingigraph_attr_idx_*)- create R wrappers for accessors from previous step if needed
- Store native
igraph_tas external pointer inigraph_t_idx_env- the native
igraph_tis an external pointer stored inunclass(graph)[[igraph_t_idx_env]]$igraph
- the native
- Rewrite C-level accessors to refer to native
igraph_t- fallback to recreating native
igraph_tfromigraph_t_idx_n,igraph_t_idx_directed,igraph_t_idx_fromandigraph_t_idx_toif the external pointer is gone - use
unserialize(serialize(graph, NULL))to test
- fallback to recreating native
- Avoid populating
igraph_t_idx_oi...igraph_t_idx_isin R - Implement ALTREP for
igraph_t_idx_fromandigraph_t_idx_to(requires R 4.0) - Double-check immutability (
INOUTinfunctions.yaml) - Double-check attribute handling
Follow-up to #783.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels