Skip to content

Commit e657cac

Browse files
committed
WIP buildSubgraph
1 parent 569c3a3 commit e657cac

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ include("entities/AbstractDFGSummary.jl")
250250

251251
include("services/AbstractDFG.jl")
252252

253+
include("services/copyFunctions.jl")
254+
253255
# In Memory Types
254256
include("GraphsDFG/GraphsDFG.jl")
255257
include("LightDFG/LightDFG.jl")

src/services/AbstractDFG.jl

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,27 @@ function getSubgraph(dfg::G,
848848
return addToDFG
849849
end
850850

851+
852+
function buildSubgraph(::Type{G}, dfg::AbstractDFG, variableFactorLabels::Vector{Symbol}, distance::Int=0; solvable::Int=0, kwargs...) where G <: AbstractDFG
853+
854+
# find neighbors at distance to add
855+
neighbors = Symbol[]
856+
if distance > 0
857+
for l in variableFactorLabels
858+
union!(neighbors, getNeighborhood(dfg, l, distance))
859+
end
860+
end
861+
862+
allvarfacs = union(variableFactorLabels, neighbors)
863+
864+
solvable != 0 && filter!(nlbl -> (getSolvable(dfg, nlbl) >= solvable), allvarfacs)
865+
866+
# Copy the section of graph we want
867+
destDFG = deepcopyGraph(G, dfg, allvarfacs; kwargs...)
868+
return destDFG
869+
end
870+
871+
851872
"""
852873
$(SIGNATURES)
853874
Common function for copying nodes from one graph into another graph.
@@ -1002,9 +1023,9 @@ Produces a dot-format of the graph for visualization.
10021023
"""
10031024
function toDot(dfg::AbstractDFG)::String
10041025
#TODO implement convert
1005-
graphsdfg = GraphsDFG{NoSolverParams}()
1006-
DistributedFactorGraphs._copyIntoGraph!(dfg, graphsdfg, union(listVariables(dfg), listFactors(dfg)), true)
1007-
1026+
# graphsdfg = GraphsDFG{NoSolverParams}()
1027+
# DistributedFactorGraphs._copyIntoGraph!(dfg, graphsdfg, union(listVariables(dfg), listFactors(dfg)), true)
1028+
graphsdfg = convert(GraphsDFG{NoSolverParams}, dfg)
10081029
# Calls down to GraphsDFG.toDot
10091030
return toDot(graphsdfg)
10101031
end

0 commit comments

Comments
 (0)