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

CGDFG also needs findShortestPathDijkstra #713

Open
dehann opened this issue Dec 13, 2020 · 0 comments
Open

CGDFG also needs findShortestPathDijkstra #713

dehann opened this issue Dec 13, 2020 · 0 comments

Comments

@dehann
Copy link
Member

dehann commented Dec 13, 2020

Prototype here:

function findShortestPathDijkstra end

LightDFG already has an implementation:

"""
$SIGNATURES
Speciallized function available to only LightDFG at this time.
Example
```julia
using IncrementalInference
# canonical example graph as example
fg = generateCanonicalFG_Kaess()
@show path = findShortestPathDijkstra(fg, :x1, :x3)
@show isVariable.(path)
@show isFactor.(path)
```
DevNotes
- # TODO expand to other AbstractDFG entities.
Related
[findFactorsBetweenNaive](@ref), `LightGraphs.dijkstra_shortest_paths`
"""
function findShortestPathDijkstra( dfg::LightDFG,
from::Symbol,
to::Symbol )
#
# LightDFG internally uses Integers
frI = dfg.g.labels[from]
toI = dfg.g.labels[to]
path = LightGraphs.dijkstra_shortest_paths(dfg.g.graph, [toI;])
# path = LightGraphs.enumerate_paths(path_state, toI)
# assemble into the list
dijkpath = Symbol[]
# test for connectivity
if path.dists[frI] < Inf
cursor = frI
push!(dijkpath, dfg.g.labels[cursor])
# walk the path
while cursor != toI
cursor = path.parents[cursor]
push!(dijkpath, dfg.g.labels[cursor])
end
end
# return the list of symbols
return dijkpath
end

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

No branches or pull requests

1 participant