Skip to content

Commit 6f33a96

Browse files
committed
getSubGraphAroundNode from LightGraphsDFG to AbstractDFG
1 parent 28b2173 commit 6f33a96

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/LightGraphsDFG/services/LightGraphsDFG.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,22 @@ function getSubgraphAroundNode(dfg::LightGraphsDFG{P}, node::T, distance::Int64=
470470
return addToDFG
471471
end
472472

473+
474+
function getSubgraphAroundNode(dfg::LightGraphsDFG{<:AbstractParams}, node::DFGNode, distance::Int64=1, includeOrphanFactors::Bool=false, addToDFG::AbstractDFG=LightGraphsDFG{P}())::AbstractDFG
475+
if !haskey(dfg.g.metaindex[:label], node.label)
476+
error("Variable/factor with label '$(node.label)' does not exist in the factor graph")
477+
end
478+
479+
# Get a list of all unique neighbors inside 'distance'
480+
ns = neighborhood(dfg.g, dfg.g[node.label,:label], distance)
481+
482+
# Copy the section of graph we want
483+
_copyIntoGraph!(dfg, addToDFG, map(n->get_prop(dfg.g, n, :label), ns), includeOrphanFactors)
484+
# _copyIntoGraph!(dfg, addToDFG, ns, includeOrphanFactors)
485+
return addToDFG
486+
end
487+
488+
473489
"""
474490
$(SIGNATURES)
475491
Get a deep subgraph copy from the DFG given a list of variables and factors.

0 commit comments

Comments
 (0)