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

Should Graphs.jl algorithms automatically work on a NamedDimGraph? #12

Closed
JoeyT1994 opened this issue Nov 25, 2022 · 2 comments
Closed

Comments

@JoeyT1994
Copy link
Contributor

I was trying to use some shortest path algorithms from Graphs.jl on NamedDimGraphs, e.g:

image

Using some of the traversal algorithms defined here: https://juliagraphs.org/Graphs.jl/dev/algorithms/shortestpaths/#Graphs.johnson_shortest_paths-Union{Tuple{AbstractGraph{U}},%20Tuple{T},%20Tuple{U},%20Tuple{AbstractGraph{U},%20AbstractMatrix{T}}}%20where%20{U%3C:Integer,%20T%3C:Real}

Is it possible to export these into NamedGraphs.jl? I can then fork and add a function which creates a subgraph of a NamedDimGraph containing only the vertices within a certain pathlength of a source_vertex. Such a function could then be utilised in ITensorNetworks.jl to orthogonalise a network up to some distance r from a source_vertex.

@mtfishman
Copy link
Member

Good question. That is the goal, however some functions in Graphs.jl don't handle general vertex types so don't automatically work. More specifically, many Graphs.jl functions assume the vertices are integers from 1 to nv(graph) and make use of that in their implementations and type signatures, like you are seeing in the error message above. If you hit on Graphs.jl functions that don't work for NamedGraphs.jl types, please raise an issue about it, and in fact we should keep track of a list of functions that need to be wrapped properly by NamedGraphs.jl.

In general it is pretty easy to add wrappers, which mostly involve calling the Graphs.jl function on the parent graph which you can extract with parent_graph(named_graph), and then possibly converting back and forth between named vertices and integer vertices of the parent graph using vertex_to_parent_vertex(named_graph, vertex) and parent_vertex_to_vertex(graph, parent_vertex)

@mtfishman
Copy link
Member

I started an issue where we can track Graphs.jl functions that need to be wrapped in #14, so I'll close this in favor of that issue.

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

No branches or pull requests

2 participants