-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Disturbed layout in subgraph #775
Comments
Probably a consequence of R's vector recycling behaviour? The graph attribute named |
@krlmlr Feel free to re-assign it to one of your teammates if needed. |
The problem is that the layout matrix of the subgraph is inherited from the original graph. To avoid this, the graph$layout attribute should not be copied to the subgraph. Or else the coordinates of the missing vertices should be removed (nicer solution). |
@krlmlr @vtraag These sorts of issues are why I think that visualization can't (or shouldn't) be handed off wholesale to another package in igraph 2. Part of it will always be igraph's business. The storage of coordinates or visualization methods, and the expected behaviour with various stored visualization information is just one example. |
What are action points here then according to you @szhorvat? A big overhaul of how the coordinates are stored? |
That's the only thing I think we can do ... will there ever be enough resources for this? I don't know. See the old igraph 2 planning document: https://github.com/igraph/rigraph/wiki/igraph-2-planning Ambitions got deflated quite a bit since then, as it became here how much all of this would take. |
Should this be closed as non planned then, as the idea is tracked in that document? |
That document does not replace the issue tracker, and is in need of an update. It's up to Kirill to judge how big a project we can take on. There were several ideas floating around, including offloading visualization to other packages entirely (like ggraph). Personally I don't favour that, but I admit there are good reasons to go that route. I wouldn't close this issue because it describes a very real problem that occurs frequently when working with igraph. |
Layouting belongs in igraph, not so sure about plotting. Reprex: options(conflicts.policy = list(warn = FALSE))
library(igraph)
g <- make_ring(10)
g$layout <- layout_in_circle(g)
sg <- subgraph(g, c(1, 2))
gs <- make_star(2)
gs$layout <- layout_in_circle(gs)
waldo::compare(sg$layout[, 1], gs$layout[, 1])
#> old | new
#> [1] 1 | 1 [1]
#> [2] 0.809016994374947 - -1 [2]
#> [3] 0.309016994374947 -
#> [4] -0.309016994374947 -
#> [5] -0.809016994374947 -
#> [6] -1 -
#> [7] -0.809016994374947 -
#> [8] -0.309016994374948 -
#> [9] 0.309016994374947 -
#> [10] 0.809016994374947 -
waldo::compare(sg$layout[, 2], gs$layout[, 2])
#> old | new
#> [1] 0 | 0 [1]
#> [2] 0.587785252292473 - 1.22464679914735e-16 [2]
#> [3] 0.951056516295154 -
#> [4] 0.951056516295154 -
#> [5] 0.587785252292473 -
#> [6] 1.22464679914735e-16 -
#> [7] -0.587785252292473 -
#> [8] -0.951056516295154 -
#> [9] -0.951056516295154 -
#> [10] -0.587785252292473 - Created on 2024-03-03 with reprex v2.1.0 The problem is that |
Vertex attributes |
A vertex attribute m <- matrix(1:6, ncol = 3)
data <- tibble::tibble(id = 1:2, m)
data
#> # A tibble: 2 × 2
#> id m[,1] [,2] [,3]
#> <int> <int> <int> <int>
#> 1 1 1 3 5
#> 2 2 2 4 6
arrow::as_arrow_table(data)
#> Error: Invalid: All columns must have the same length
arrow::as_arrow_array(data)
#> Error: Invalid: All arrays must have the same length Created on 2024-03-04 with reprex v2.1.0 @paleolimbot: Does Arrow support matrix columns in principle? If yes, what could the support in R look like? What about Python and other systems? |
Can't we simply keep on using |
Yes, there are "fixed-size tensor" and "variable-size tensor" extension types: https://arrow.apache.org/docs/format/CanonicalExtensions.html#fixed-shape-tensor , although neither are supported in the R bindings or nanoarrow (or: there is no built-in conversion to R objects). I prototyped it here when the discussion was ongoing: https://gist.github.com/paleolimbot/c42f068c2b8b98255dbfbe379d905607 . I am pretty sure that in Python/pyarrow it has built-in/zero-copy convert to numpy. It could in theory be wired up in nanoarrow...I'm in the middle of a refactor to make the conversion process understandable here: apache/arrow-nanoarrow#392 , and after that's done it should be more straightforward how to contribute that. |
Thanks, @paleolimbot. Looks like we'll stay with plain vector attributes for now. |
Note that vertices 1 and 2 are plotted multiple times.
This is because the layout vector of the original graph is copied to the sub graph.
Version information
The text was updated successfully, but these errors were encountered: