Skip to content
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

Fix matrix #175

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Fix matrix #175

merged 2 commits into from
Oct 30, 2023

Conversation

rmflight
Copy link
Contributor

fixes a logical test in the .matrix method, and allows passing more parameters to the underlying igraph methods.

@moritzpschwarz
Copy link

Hi @thomasp85 just for your information, I encountered the same issue, see here for a description:

https://stackoverflow.com/questions/76952759/error-in-tidygraph-as-tbl-graph-mutliple-logicals-compared-to-single

and a quick example:

library(tidygraph)
adj <- structure(c(0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2, 0, 
                   0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 
                   0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
                 dim = c(15L, 15L), 
                 dimnames = list(paste0("v",1:15), 
                                 paste0("v",1:15)))

adj

tidygraph::as_tbl_graph(adj)

The fixes by @rmflight on this branch worked for me!

@moritzpschwarz
Copy link

Small update to my issue described above, this has worked as a workaround:

adj %>%
    igraph::graph_from_adjacency_matrix(weighted = TRUE) %>%
    tidygraph::as_tbl_graph()

@thomasp85 thomasp85 merged commit 98f3443 into thomasp85:main Oct 30, 2023
@thomasp85
Copy link
Owner

matrix("Thanks", ncol = 3, nrow = 2)
#>      [,1]     [,2]     [,3]    
#> [1,] "Thanks" "Thanks" "Thanks"
#> [2,] "Thanks" "Thanks" "Thanks"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants