Skip to content

Commit c779acb

Browse files
authored
Merge pull request #102 from JuliaRobotics/hotfix/v0_3_2_orderingissue
Hotfix: v0.3.2 orderingissue
2 parents 4fa3029 + 185d74e commit c779acb

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,18 @@ function _copyIntoGraph!(sourceDFG::GraphsDFG, destDFG::GraphsDFG, variableFacto
391391
for factor in sourceFactors
392392
if !haskey(destDFG.labelDict, factor.dfgNode.label)
393393
# Get the original factor variables (we need them to create it)
394-
variables = in_neighbors(factor, sourceDFG.g)
395-
# Find the labels and associated variables in our new subgraph
394+
neighVarIds = getNeighbors(sourceDFG, factor.dfgNode.label) #OLD: in_neighbors(factor, sourceDFG.g)
395+
# Find the labels and associated neighVarIds in our new subgraph
396396
factVariables = DFGVariable[]
397-
for variable in variables
398-
if haskey(destDFG.labelDict, variable.dfgNode.label)
399-
push!(factVariables, getVariable(destDFG, variable.dfgNode.label))
397+
for neighVarId in neighVarIds
398+
if haskey(destDFG.labelDict, neighVarId)
399+
push!(factVariables, getVariable(destDFG, neighVarId))
400400
#otherwise ignore
401401
end
402402
end
403403

404404
# Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
405-
if includeOrphanFactors || length(factVariables) == length(variables)
405+
if includeOrphanFactors || length(factVariables) == length(neighVarIds)
406406
addFactor!(destDFG, factVariables, deepcopy(factor.dfgNode))
407407
end
408408
end

test/interfaceTests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ end
191191
dfgSubgraph = getSubgraph(dfg,[:x1, :x2, :x1x2f1])
192192
# Only returns x1 and x2
193193
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
194+
195+
# DFG issue #95 - confirming that getSubgraphAroundNode retains order
196+
# REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95
197+
for fId in getVariableIds(dfg)
198+
# Get a subgraph of this and it's related factors+variables
199+
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
200+
# For each factor check that the order the copied graph == original
201+
for fact in getFactors(dfgSubgraph)
202+
@test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols
203+
end
204+
end
194205
end
195206

196207
@testset "Producing Dot Files" begin

0 commit comments

Comments
 (0)