Skip to content

Commit 2928158

Browse files
committed
do we need to check for duplicates in _copyIntoGraph!()?
1 parent b5c7e01 commit 2928158

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/services/AbstractDFG.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function _copyIntoGraph!(sourceDFG::G, destDFG::H, variableFactorLabels::Vector{
4242

4343
# Now we have to add all variables first,
4444
for variable in sourceVariables
45-
addVariable!(destDFG, deepcopy(variable))
45+
if !haskey(destDFG.labelDict, variable.label)
46+
addVariable!(destDFG, deepcopy(variable))
47+
end
4648
end
4749
# And then all factors to the destDFG.
4850
for factor in sourceFactors
@@ -57,7 +59,9 @@ function _copyIntoGraph!(sourceDFG::G, destDFG::H, variableFactorLabels::Vector{
5759
end
5860
# Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
5961
if includeOrphanFactors || length(factVariableIds) == length(sourceFactorVariableIds)
60-
addFactor!(destDFG, factVariableIds, deepcopy(factor))
62+
if !haskey(destDFG.labelDict, factor.label)
63+
addFactor!(destDFG, factVariableIds, deepcopy(factor))
64+
end
6165
end
6266
end
6367
return nothing

0 commit comments

Comments
 (0)