Skip to content

Commit 424c23b

Browse files
committed
solveTree seems to work,
cc @GearsAD
1 parent 0d9640a commit 424c23b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ end
261261
List the DFGFactors in the DFG.
262262
Optionally specify a label regular expression to retrieves a subset of the factors.
263263
"""
264-
function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
265-
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, Graphs.vertices(dfg.g)))
264+
function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; solvable::Int=0)::Vector{DFGFactor}
265+
factors = map(v -> v.dfgNode, filter(n -> (n.dfgNode isa DFGFactor) && solvable <= isSolvable(n.dfgNode), Graphs.vertices(dfg.g)))
266+
266267
if regexFilter != nothing
267268
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
268269
end
@@ -288,7 +289,7 @@ function getNeighbors(dfg::GraphsDFG, node::T; solvable::Union{Nothing, Int}=not
288289
vert = dfg.g.vertices[dfg.labelDict[node.label]]
289290
neighbors = in_neighbors(vert, dfg.g) #Don't use out_neighbors! It enforces directiveness even if we don't want it
290291
# Additional filtering
291-
neighbors = ready != nothing ? filter(v -> solvable <= isSolvable(v.dfgNode), neighbors) : neighbors
292+
neighbors = solvable != nothing ? filter(v -> solvable <= isSolvable(v.dfgNode), neighbors) : neighbors
292293
neighbors = backendset != nothing ? filter(v -> isSolveInProgress(v.dfgNode) == backendset, neighbors) : neighbors
293294
# Variable sorting (order is important)
294295
if node isa DFGFactor
@@ -302,14 +303,14 @@ end
302303
$(SIGNATURES)
303304
Retrieve a list of labels of the immediate neighbors around a given variable or factor specified by its label.
304305
"""
305-
function getNeighbors(dfg::GraphsDFG, label::Symbol; ready::Union{Nothing, Int}=nothing, backendset::Union{Nothing, Int}=nothing)::Vector{Symbol} where T <: DFGNode
306+
function getNeighbors(dfg::GraphsDFG, label::Symbol; solvable::Union{Nothing, Int}=nothing, backendset::Union{Nothing, Int}=nothing)::Vector{Symbol} where T <: DFGNode
306307
if !haskey(dfg.labelDict, label)
307308
error("Variable/factor with label '$(label)' does not exist in the factor graph")
308309
end
309310
vert = dfg.g.vertices[dfg.labelDict[label]]
310311
neighbors = in_neighbors(vert, dfg.g) #Don't use out_neighbors! It enforces directiveness even if we don't want it
311312
# Additional filtering
312-
neighbors = ready != nothing ? filter(v -> isSolvable(v.dfgNode) >= ready, neighbors) : neighbors
313+
neighbors = solvable != nothing ? filter(v -> isSolvable(v.dfgNode) >= solvable, neighbors) : neighbors
313314
neighbors = backendset != nothing ? filter(v -> isSolveInProgress(v.dfgNode) == backendset, neighbors) : neighbors
314315
# Variable sorting when using a factor (function order is important)
315316
if vert.dfgNode isa DFGFactor

src/services/AbstractDFG.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,10 @@ Get an adjacency matrix for the DFG, returned as a Matrix{Union{Nothing, Symbol}
472472
Rows are all factors, columns are all variables, and each cell contains either nothing or the symbol of the relating factor.
473473
The first row and first column are factor and variable headings respectively.
474474
"""
475-
function getAdjacencyMatrix(dfg::G)::Matrix{Union{Nothing, Symbol}} where G <: AbstractDFG
476-
varLabels = sort(map(v->v.label, getVariables(dfg)))
475+
function getAdjacencyMatrix(dfg::AbstractDFG;
476+
solvable::Int=1)::Matrix{Union{Nothing, Symbol}}
477+
#
478+
varLabels = sort(map(v->v.label, getVariables(dfg)))
477479
factLabels = sort(map(f->f.label, getFactors(dfg)))
478480
vDict = Dict(varLabels .=> [1:length(varLabels)...].+1)
479481

0 commit comments

Comments
 (0)