@@ -1002,6 +1002,43 @@ function GettingSubgraphs(testDFGAPI; VARTYPE=DFGVariable, FACTYPE=DFGFactor)
1002
1002
1003
1003
end
1004
1004
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
+
1005
1042
# TODO Summaries and Summary Graphs
1006
1043
function Summaries (testDFGAPI)
1007
1044
# "Summaries and Summary Graphs"
0 commit comments