Skip to content

Commit f788416

Browse files
committed
Merge branch 'master' into release/v0.10
2 parents 29b79ae + beb3a47 commit f788416

File tree

6 files changed

+69
-5
lines changed

6 files changed

+69
-5
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.10.8"
3+
version = "0.10.9"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -36,7 +36,7 @@ Pkg = "1.4, 1.5"
3636
Reexport = "0.2, 0.3, 0.4, 0.5, 1"
3737
Requires = "0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 1"
3838
TimeZones = "1.3.1"
39-
Unmarshal = "= 0.4.0"
39+
Unmarshal = "0.4"
4040
julia = "1.2"
4141

4242
[extras]

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ export @defVariable
232232
export saveDFG, loadDFG!, loadDFG
233233
export toDot, toDotFile
234234

235+
# shortest path
236+
export findShortestPathDijkstra
237+
235238
# Comparisons
236239
export
237240
compare,

src/LightDFG/LightDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ import ...DistributedFactorGraphs: setSolverParams!,
4545
getBiadjacencyMatrix,
4646
_getDuplicatedEmptyDFG,
4747
toDot,
48-
toDotFile
48+
toDotFile,
49+
findShortestPathDijkstra
4950

5051
include("FactorGraphs/FactorGraphs.jl")
5152
using .FactorGraphs

src/LightDFG/services/LightDFG.jl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,55 @@ function toDot(dfg::LightDFG)::String
359359
close(m)
360360
return String(data)
361361
end
362+
363+
364+
"""
365+
$SIGNATURES
366+
367+
Speciallized function available to only LightDFG at this time.
368+
369+
Example
370+
```julia
371+
using IncrementalInference
372+
373+
# canonical example graph as example
374+
fg = generateCanonicalFG_Kaess()
375+
376+
@show path = findShortestPathDijkstra(fg, :x1, :x3)
377+
@show isVariable.(path)
378+
@show isFactor.(path)
379+
```
380+
381+
DevNotes
382+
- # TODO expand to other AbstractDFG entities.
383+
384+
Related
385+
386+
[findFactorsBetweenNaive](@ref), `LightGraphs.dijkstra_shortest_paths`
387+
"""
388+
function findShortestPathDijkstra( dfg::LightDFG,
389+
from::Symbol,
390+
to::Symbol )
391+
#
392+
# LightDFG internally uses Integers
393+
frI = dfg.g.labels[from]
394+
toI = dfg.g.labels[to]
395+
396+
path = LightGraphs.dijkstra_shortest_paths(dfg.g.graph, [toI;])
397+
398+
# assemble into the list
399+
dijkpath = Symbol[]
400+
# test for connectivity
401+
if path.dists[frI] < Inf
402+
cursor = frI
403+
push!(dijkpath, dfg.g.labels[cursor])
404+
# walk the path
405+
while cursor != toI
406+
cursor = path.parents[cursor]
407+
push!(dijkpath, dfg.g.labels[cursor])
408+
end
409+
end
410+
411+
# return the list of symbols
412+
return dijkpath
413+
end

src/services/AbstractDFG.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ end
10211021
## Automated Graph Searching
10221022
##==============================================================================
10231023

1024+
1025+
function findShortestPathDijkstra end
1026+
10241027
"""
10251028
$SIGNATURES
10261029
@@ -1029,7 +1032,11 @@ Relatively naive function counting linearly from-to
10291032
DevNotes
10301033
- Convert to using LightGraphs shortest path methods instead.
10311034
"""
1032-
function findFactorsBetweenNaive(dfg::AbstractDFG, from::Symbol, to::Symbol, assertSingles::Bool=false)
1035+
function findFactorsBetweenNaive( dfg::AbstractDFG,
1036+
from::Symbol,
1037+
to::Symbol,
1038+
assertSingles::Bool=false)
1039+
#
10331040
@info "findFactorsBetweenNaive is naive linear number method -- improvements welcome"
10341041
SRT = getVariableLabelNumber(from)
10351042
STP = getVariableLabelNumber(to)

src/services/Serialization.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ function getTypeFromSerializationModule(softtypeString::String)
8888
ret = if 1 < length(noparams)
8989
# fix #671, but does not work with specific module yet
9090
bidx = findfirst(r"{", split_st[end])[1]
91-
eval(Base.Meta.parse("Main.$(noparams[1])$(split_st[end][bidx:end])"))
91+
Core.eval(m, Base.Meta.parse("$(noparams[1])$(split_st[end][bidx:end])"))
92+
# eval(Base.Meta.parse("Main.$(noparams[1])$(split_st[end][bidx:end])"))
9293
else
9394
getfield(m, Symbol(split_st[end]))
9495
end

0 commit comments

Comments
 (0)