Skip to content

Commit ea6ba28

Browse files
committed
add solvable filter to GraphsDFG
1 parent 3526701 commit ea6ba28

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export pushUserData!, pushRobotData!, pushSessionData!, popUserData!, popRobotDa
3333

3434
# Services/AbstractDFG Exports
3535
export hasFactor, hasVariable, isInitialized, getFactorFunction, isVariable, isFactor
36+
export isSolvable
3637
export mergeUpdateVariableSolverData!, mergeUpdateGraphSolverData!
3738

3839
# Solver (IIF) Exports

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,20 @@ end
235235
List the DFGVariables in the DFG.
236236
Optionally specify a label regular expression to retrieves a subset of the variables.
237237
"""
238-
function getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
239-
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, Graphs.vertices(dfg.g)))
238+
function getVariables(dfg::GraphsDFG,
239+
regexFilter::Union{Nothing, Regex}=nothing;
240+
tags::Vector{Symbol}=Symbol[],
241+
solvable::Int=0 )::Vector{DFGVariable}
242+
#
243+
variables = map(v -> v.dfgNode, filter(n -> (n.dfgNode isa DFGVariable) && (solvable <= isSolvable(n.dfgNode)), Graphs.vertices(dfg.g)))
244+
# filter on solvable
245+
246+
# filter on regex
240247
if regexFilter != nothing
241248
variables = filter(v -> occursin(regexFilter, String(v.label)), variables)
242249
end
250+
251+
# filter on tags
243252
if length(tags) > 0
244253
mask = map(v -> length(intersect(v.tags, tags)) > 0, variables )
245254
return variables[mask]

0 commit comments

Comments
 (0)