Skip to content

Commit e797a16

Browse files
committed
Tags on listFactors and lsf
1 parent 932ff2a commit e797a16

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ function getFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=noth
339339
return map(vId->getFactor(dfg, vId), factorIds)
340340
end
341341

342-
function listFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; solvable::Int=0)::Vector{Symbol}
342+
function listFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0)::Vector{Symbol}
343343
# Optimized for DB call
344+
length(tags) > 0 @error "Filter on tags not implemented for CloudGraphsDFG"
344345
if regexFilter == nothing
345346
return _getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId):FACTOR) where node.solvable >= $solvable")
346347
else

src/LightDFG/services/LightDFG.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ function getFactors(dfg::LightDFG, regexFilter::Union{Nothing, Regex}=nothing; t
184184
return factors
185185
end
186186

187-
function listFactors(dfg::LightDFG, regexFilter::Union{Nothing, Regex}=nothing; solvable::Int=0)::Vector{Symbol}
187+
function listFactors(dfg::LightDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0)::Vector{Symbol}
188188
# factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
189+
if length(tags) > 0
190+
return map(v -> v.label, getFactor(dfg, regexFilter, tags=tags, solvable=solvable))
191+
end
189192
factors = collect(keys(dfg.g.factors))
190193
if regexFilter != nothing
191194
factors = filter(f -> occursin(regexFilter, String(f)), factors)

src/services/AbstractDFG.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,19 @@ end
292292
$(SIGNATURES)
293293
Checks if the graph is fully connected, returns true if so.
294294
"""
295-
function isFullyConnected(dfg::G)::Bool where G <: AbstractDFG
295+
function isFullyConnected(dfg::AbstractDFG)::Bool
296296
error("isFullyConnected not implemented for $(typeof(dfg))")
297297
end
298298

299299
"""
300300
$(SIGNATURES)
301301
Retrieve a list of labels of the immediate neighbors around a given variable or factor specified by its label.
302302
"""
303-
function getNeighbors(dfg::G, label::Symbol; solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
304-
error("getNeighbors not implemented for $(typeof(dfg))")
305-
end
306-
##TODO reduce with getNeighbors(dfg, node.label)
307-
function getNeighbors(dfg::G, node::T; solvable::Int=0)::Vector{Symbol} where {G <: AbstractDFG, T <: DFGNode}
303+
function getNeighbors(dfg::AbstractDFG, label::Symbol; solvable::Int=0)::Vector{Symbol}
308304
error("getNeighbors not implemented for $(typeof(dfg))")
309305
end
310306

307+
311308
##------------------------------------------------------------------------------
312309
## copy and duplication
313310
##------------------------------------------------------------------------------
@@ -416,6 +413,11 @@ end
416413
##------------------------------------------------------------------------------
417414
## Connectivity Alias
418415
##------------------------------------------------------------------------------
416+
417+
function getNeighbors(dfg::AbstractDFG, node::DFGNode; solvable::Int=0)::Vector{Symbol}
418+
getNeighbors(dfg, node.label, solvable=solvable)
419+
end
420+
419421
#Alias
420422
#TODO rather actually check if there are orphaned factors (factors without all variables)
421423
"""
@@ -457,8 +459,8 @@ end
457459
Get a list of the IDs (labels) of the DFGFactors in the DFG.
458460
Optionally specify a label regular expression to retrieves a subset of the factors.
459461
"""
460-
function listFactors(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
461-
return map(f -> f.label, getFactors(dfg, regexFilter, solvable=solvable))
462+
function listFactors(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
463+
return map(f -> f.label, getFactors(dfg, regexFilter, tags=tags, solvable=solvable))
462464
end
463465

464466
##------------------------------------------------------------------------------
@@ -485,8 +487,8 @@ end
485487
List the DFGFactors in the DFG.
486488
Optionally specify a label regular expression to retrieves a subset of the factors.
487489
"""
488-
function lsf(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
489-
return listFactors(dfg, regexFilter, solvable=solvable)
490+
function lsf(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
491+
return listFactors(dfg, regexFilter, tags=tags, solvable=solvable)
490492
end
491493

492494

0 commit comments

Comments
 (0)