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

Support for multiple target nodes in to_shortest_path #83

Open
krlmlr opened this issue Dec 7, 2018 · 2 comments
Open

Support for multiple target nodes in to_shortest_path #83

krlmlr opened this issue Dec 7, 2018 · 2 comments
Labels
feature a feature request or enhancement

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Dec 7, 2018

This currently doesn't seem to work, see reprex. It looks like only a small change will be required, but I might be wrong. Would you support multiple target nodes (default: all nodes) in to_shortest_path()?

library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
play_geometry(10, 3) %>%
  morph(to_shortest_path, from = 1, to = 2:10) %>%
  crystallize() %>%
  pull()
#> [[1]]
#> # A tbl_graph: 2 nodes and 1 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Node Data: 2 x 3 (active)
#>        x     y .tidygraph_node_index
#>    <dbl> <dbl>                 <int>
#> 1 0.0952 0.307                     1
#> 2 0.146  0.651                     2
#> #
#> # Edge Data: 1 x 3
#>    from    to .tidygraph_edge_index
#>   <int> <int>                 <int>
#> 1     1     2                     1

Created on 2018-12-08 by the reprex package (v0.2.1.9000)

@krlmlr
Copy link
Contributor Author

krlmlr commented Dec 8, 2018

Also, can we get a to_distances() morpher that adds the distance as a node attribute?

All of this presumes that from is restricted to a single node.

@thomasp85
Copy link
Owner

I'll look into this. I don't think a to_distances() morphed makes sense as it does not change the graph structure (which is the purpose of morphers)... You should be able to get what you want using mutate(dist = node_distance_to(...)) or something like that

@thomasp85 thomasp85 added the feature a feature request or enhancement label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants