Skip to content

Commit c9edb00

Browse files
committed
test buildSubgraph
1 parent cf6e407 commit c9edb00

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ export packVariableNodeData, unpackVariableNodeData
161161

162162
export getSolvedCount, isSolved, setSolvedCount!, isInitialized
163163

164-
export getNeighborhood, getSubgraph, getSubgraphAroundNode, getNeighbors, _getDuplicatedEmptyDFG
165-
164+
export getNeighborhood, getNeighbors, _getDuplicatedEmptyDFG
165+
export buildSubgraph
166+
# TODO Deprecate in favor of buildSubgraph
167+
export getSubgraph, getSubgraphAroundNode
166168
# Big Data
167169
##------------------------------------------------------------------------------
168170
export addBigDataEntry!, getBigDataEntry, updateBigDataEntry!, deleteBigDataEntry!, getBigDataEntries, getBigDataKeys

test/interfaceTests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ end
7070
GettingSubgraphs(testDFGAPI)
7171
end
7272

73+
@testset "Building Subgraphs" begin
74+
BuildingSubgraphs(testDFGAPI)
75+
end
76+
7377
#TODO Summaries and Summary Graphs
7478
@testset "Summaries and Summary Graphs" begin
7579
Summaries(testDFGAPI)

test/testBlocks.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,43 @@ function GettingSubgraphs(testDFGAPI; VARTYPE=DFGVariable, FACTYPE=DFGFactor)
10021002

10031003
end
10041004

1005+
1006+
function BuildingSubgraphs(testDFGAPI; VARTYPE=DFGVariable, FACTYPE=DFGFactor)
1007+
1008+
# "Getting Subgraphs"
1009+
dfg, verts, facs = connectivityTestGraph(testDFGAPI, VARTYPE=VARTYPE, FACTYPE=FACTYPE)
1010+
# Subgraphs
1011+
dfgSubgraph = buildSubgraph(testDFGAPI, dfg, [verts[1].label], 2)
1012+
# Only returns x1 and x2
1013+
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
1014+
#
1015+
dfgSubgraph = buildSubgraph(testDFGAPI, dfg, [:x1, :x2, :x1x2f1])
1016+
# Only returns x1 and x2
1017+
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
1018+
1019+
dfgSubgraph = buildSubgraph(testDFGAPI, dfg, [:x1x2f1], 1)
1020+
# Only returns x1 and x2
1021+
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
1022+
1023+
#TODO if not a LightDFG with and summary or skeleton
1024+
if VARTYPE == DFGVariable
1025+
dfgSubgraph = buildSubgraph(testDFGAPI, dfg, [:x8], 2, solvable=1)
1026+
@test issetequal([:x7], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...])
1027+
#end if not a LightDFG with and summary or skeleton
1028+
end
1029+
# DFG issue #95 - confirming that getSubgraphAroundNode retains order
1030+
# REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95
1031+
for fId in listVariables(dfg)
1032+
# Get a subgraph of this and it's related factors+variables
1033+
dfgSubgraph = buildSubgraph(testDFGAPI, dfg, [fId], 2)
1034+
# For each factor check that the order the copied graph == original
1035+
for fact in getFactors(dfgSubgraph)
1036+
@test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols
1037+
end
1038+
end
1039+
1040+
end
1041+
10051042
#TODO Summaries and Summary Graphs
10061043
function Summaries(testDFGAPI)
10071044
# "Summaries and Summary Graphs"

0 commit comments

Comments
 (0)