Closed szhorvat closed 10 months ago
Agree to break it and see what the revdepchecks say.
If everything fails, we can implement the as_adjacency_matrix(g, sparse = F, attr = "foo")
case by wrapping as_adjacency_matrix(g, sparse = F)
and performing a lookup.
Seems we're good here.
At the moment,
as_adjacency_matrix
is mostly implemented in R. In 0.10, we have almost everything in place to rely on this C core for this. This is important because there are subtleties with counting self-loops in undirected graphs, which should work the same way across all interfaces of igraph, and more importantly: across all implementations of the adjacency matrix conversion functions. The code paths that use the C core should produce the same kinds of results as the code paths that use pure-R implementations.There is one currently piece of functionality that is not implemented in the C core: creating adjacency matrices that are non-numerical.
Here's a small demo of this functionality with the current
main
branch:As you can see, the dense adj mat function supports multiple different non-numeric types, while the sparse version supports numeric and logical.
@krlmlr We need to make a decision about how to handle this during the 0.10 upgrade. Please comment here so we have the decision in writing.
My suggestion:
loops='once'
orloops='ignore'
, and counting loops once/twice only makes sense for the numerical case.This is for reasons of practicality. I suspect very few people use this functionality, but I'm not sure. If we have unlimited time, I'd be in favour of re-implementing it.
Finally, I'd like to note that it is somewhat pointless to use logical types as weights when building an adjacency matrix, as zeros effectively eliminate the corresponding edge. So we can't convert back to a graph from the adj mat and preserve all edges.