-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in mapper2D$adjacency #6
Comments
Hi Pablo, Are you using the version of TDAmapper on github or CRAN? Given that you're filing a github issue, I think it's likely that you're using the github version, but would like to verify that before looking at fixing the issue. (The CRAN version is likely out of date and may have more bugs, but the github version is the best version available.) Thanks! Paul |
Hi Paul, I am using the Github version. Thanks, Pablo |
Sorry for the multiple emails... This is a much more efficient implementation of the function #include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericMatrix adjacencyCpp(List x) {
List xlist(x);
int n = xlist.size();
NumericMatrix res(n,n);
for(int i=0; i<n-1; i++) {
NumericVector loc1 = xlist[i];
for(int j=i+1; j<n; j++) {
NumericVector loc2 = xlist[j];
if (intersect(loc1,loc2).length() > 0) {
res(i,j) = 1;
res(j,i) = 1;
};
};
};
return res;
} Then, in R: library(Rcpp)
sourceCpp('adjacency.cpp')
adjacencyCpp(m2$points_in_vertex)[1:7,1:7]
|
Correct me if I'm wrong on any of this, but I think perhaps this is actually not due to the computation of the adjacency matrix, but in the admissibility criteria of which level sets are considered? It looks like maybe here only adjacent level sets are considered, which works when the overlap is < 50%. You can kind of see that here: The nodes pairs (1,3), (3,6), (2,5), and (4,7) are all in adjacent level sets:
but the pair (1, 6) is not. I have a pull request that (implicitly) takes care of this issue. Using the code from that PR:
I get the following. As you can see, (1, 6) are linked.
|
Hi,
There seems to be a bug in
mapper2D$adjacency
(and I did not checkmapper1D$adjacency
; potentially it is also there). For instance, consider the following example:and let us look at the first 7 vertices:
There should be edges at (1,3), (1,6), (3,6), (2,5), and (4,7). However,
m2$adjacency
misses the (1,6) edge:The following code I think would correctly compute the adjacency matrix and can be potentially useful to fix the bug (although I am sure there are more efficient ways to do it):
By the way, thanks for this repository. It is really useful.
Best,
Pablo
The text was updated successfully, but these errors were encountered: