@@ -258,7 +258,7 @@ function getFactors(
258258 filterDFG! (factors, labelFilter, (String ∘ getLabel))
259259 filterDFG! (factors, solvableFilter, getSolvable)
260260 filterDFG! (factors, tagsFilter, getTags)
261- filterDFG! (factors, typeFilter, getFactorType)
261+ filterDFG! (factors, typeFilter, typeof ∘ getFactorType)
262262 return factors
263263end
264264
@@ -304,17 +304,27 @@ function isConnected(dfg::GraphsDFG)
304304 # return length(Graphs.connected_components(dfg.g)) == 1
305305end
306306
307+ _isSolvable (dfg:: GraphsDFG , label:: Symbol , ready:: Nothing ) = true
308+
307309function _isSolvable (dfg:: GraphsDFG , label:: Symbol , ready:: Int )
308310 haskey (dfg. g. variables, label) && (return dfg. g. variables[label]. solvable >= ready)
309311 haskey (dfg. g. factors, label) && (return dfg. g. factors[label]. solvable >= ready)
310312 throw (LabelNotFoundError (label))
311313end
312314
313- function listNeighbors (dfg:: GraphsDFG , node:: AbstractGraphNode ; solvable:: Int = 0 )
315+ function listNeighbors (
316+ dfg:: GraphsDFG ,
317+ node:: AbstractGraphNode ;
318+ solvable:: Union{Nothing, Int} = nothing ,
319+ )
314320 return listNeighbors (dfg, node. label; solvable)
315321end
316322
317- function listNeighbors (dfg:: GraphsDFG , label:: Symbol ; solvable:: Int = 0 )
323+ function listNeighbors (
324+ dfg:: GraphsDFG ,
325+ label:: Symbol ;
326+ solvable:: Union{Nothing, Int} = nothing ,
327+ )
318328 if ! (hasVariable (dfg, label) || hasFactor (dfg, label))
319329 throw (LabelNotFoundError (label))
320330 end
@@ -337,7 +347,7 @@ function listNeighborhood(
337347 dfg:: GraphsDFG ,
338348 variableFactorLabels:: Vector{Symbol} ,
339349 distance:: Int ;
340- solvable:: Int = 0 ,
350+ solvable:: Union{Nothing, Int} = nothing ,
341351)
342352 # find neighbors at distance to add
343353 nbhood = Int[]
@@ -348,7 +358,8 @@ function listNeighborhood(
348358
349359 allvarfacs = [dfg. g. labels[id] for id in nbhood]
350360
351- solvable != 0 && filter! (nlbl -> (getSolvable (dfg, nlbl) >= solvable), allvarfacs)
361+ ! isnothing (solvable) &&
362+ filter! (nlbl -> (getSolvable (dfg, nlbl) >= solvable), allvarfacs)
352363
353364 return allvarfacs
354365end
365376# Biadjacency Matrix https://en.wikipedia.org/wiki/Adjacency_matrix#Of_a_bipartite_graph
366377function getBiadjacencyMatrix (
367378 dfg:: GraphsDFG ;
368- solvable:: Int = 0 ,
369- varLabels = listVariables (dfg; solvable = solvable ),
370- factLabels = listFactors (dfg; solvable = solvable ),
379+ solvable:: Union{Nothing, Int} = nothing ,
380+ varLabels = listVariables (dfg; solvable),
381+ factLabels = listFactors (dfg; solvable),
371382)
372383 varIndex = [dfg. g. labels[s] for s in varLabels]
373384 factIndex = [dfg. g. labels[s] for s in factLabels]
@@ -443,7 +454,7 @@ function findShortestPathDijkstra(
443454 tagsFactors:: Vector{Symbol} = Symbol[],
444455 typeVariables:: Union{Nothing, <:AbstractVector} = nothing ,
445456 typeFactors:: Union{Nothing, <:AbstractVector} = nothing ,
446- solvable:: Int = 0 ,
457+ solvable:: Union{Nothing, Int} = nothing ,
447458 initialized:: Union{Nothing, Bool} = nothing ,
448459)
449460 #
@@ -458,14 +469,14 @@ function findShortestPathDijkstra(
458469
459470 #
460471 duplicate =
461- regexVariables != = nothing ||
462- regexFactors != = nothing ||
463- 0 < length (tagsVariables) ||
464- 0 < length (tagsFactors) ||
465- typeVariables != = nothing ||
466- typeFactors != = nothing ||
467- initialized != = nothing ||
468- solvable != 0
472+ ! isnothing (regexVariables) ||
473+ ! isnothing (regexFactors) ||
474+ ! isempty (tagsVariables) ||
475+ ! isempty (tagsFactors) ||
476+ ! isnothing (typeVariables) ||
477+ ! isnothing (typeFactors) ||
478+ ! isnothing (initialized) ||
479+ ! isnothing (solvable)
469480 #
470481 dfg_ = if duplicate
471482 # use copy if filter is being applied
0 commit comments