Skip to content

Commit c861c6c

Browse files
committed
Use Abstract Factor and Variable and not Node in Light FG
1 parent 118b548 commit c861c6c

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/LightDFG/FactorGraphs/FactorGraphs.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,22 @@ export
3131
filter_vertices,
3232
reverse
3333

34-
import DistributedFactorGraphs: DFGNode
35-
const AbstractNodeType = DFGNode
34+
# import DistributedFactorGraphs: DFGNode
35+
# const AbstractNodeType = DFGNode
36+
import DistributedFactorGraphs: AbstractDFGVariable, AbstractDFGFactor
37+
const AbstractVariableType = AbstractDFGVariable
38+
const AbstractFactorType = AbstractDFGFactor
3639

3740
include("BiMaps.jl")
3841

39-
struct FactorGraph{T <: Integer,V <: AbstractNodeType, F <: AbstractNodeType} <: AbstractGraph{T}
42+
struct FactorGraph{T <: Integer,V <: AbstractVariableType, F <: AbstractFactorType} <: AbstractGraph{T}
4043
graph::SimpleGraph{T}
4144
labels::BiDictMap{T}
4245
variables::Dict{Symbol,V}
4346
factors::Dict{Symbol,F}
4447
end
4548

46-
function FactorGraph{T, V, F}(nv::Int=100, nf::Int=100) where {T <: Integer, V <: AbstractNodeType, F <: AbstractNodeType}
49+
function FactorGraph{T, V, F}(nv::Int=100, nf::Int=100) where {T <: Integer, V <: AbstractVariableType, F <: AbstractFactorType}
4750
fadjlist = Vector{Vector{T}}()
4851
sizehint!(fadjlist, nv + nf)
4952
g = SimpleGraph{T}(0, fadjlist)
@@ -55,10 +58,10 @@ function FactorGraph{T, V, F}(nv::Int=100, nf::Int=100) where {T <: Integer, V <
5558
return FactorGraph{T, V, F}(g, labels, variables, factors)
5659
end
5760

58-
# fg = FactorGraph{Int, AbstractNodeType, AbstractNodeType}()
61+
# fg = FactorGraph{Int, AbstractVariableType, AbstractFactorType}()
5962

60-
FactorGraph() = FactorGraph{Int, AbstractNodeType, AbstractNodeType}()
61-
FactorGraph{V,F}() where {V <: AbstractNodeType, F <: AbstractNodeType} = FactorGraph{Int, V, F}()
63+
FactorGraph() = FactorGraph{Int, AbstractVariableType, AbstractFactorType}()
64+
FactorGraph{V,F}() where {V <: AbstractVariableType, F <: AbstractFactorType} = FactorGraph{Int, V, F}()
6265

6366

6467
function show(io::IO, g::FactorGraph)

src/LightDFG/services/LightDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ exists(dfg::LightDFG, node::DFGNode) = exists(dfg, node.label)
3535
$(SIGNATURES)
3636
Add a DFGVariable to a DFG.
3737
"""
38-
function addVariable!(dfg::LightDFG, variable::V)::Bool where V <: AbstractDFGVariable
38+
function addVariable!(dfg::LightDFG{<:AbstractParams, V, <:AbstractDFGFactor}, variable::V)::Bool where V <: AbstractDFGVariable
3939
#TODO should this be an error
4040
if haskey(dfg.g.variables, variable.label)
4141
error("Variable '$(variable.label)' already exists in the factor graph")
@@ -56,7 +56,7 @@ end
5656
$(SIGNATURES)
5757
Add a DFGFactor to a DFG.
5858
"""
59-
function addFactor!(dfg::LightDFG, variables::Vector{V}, factor::F)::Bool where {V <: AbstractDFGVariable, F <: AbstractDFGFactor}
59+
function addFactor!(dfg::LightDFG{<:AbstractParams, V, F}, variables::Vector{V}, factor::F)::Bool where {V <: AbstractDFGVariable, F <: AbstractDFGFactor}
6060
# if haskey(dfg.g.metaindex[:label], factor.label)
6161
# error("Factor '$(factor.label)' already exists in the factor graph")
6262
# end
@@ -82,7 +82,7 @@ end
8282
$(SIGNATURES)
8383
Add a DFGFactor to a DFG.
8484
"""
85-
function addFactor!(dfg::LightDFG, variableLabels::Vector{Symbol}, factor::F)::Bool where F <: AbstractDFGFactor
85+
function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, variableLabels::Vector{Symbol}, factor::F)::Bool where F <: AbstractDFGFactor
8686
#TODO should this be an error
8787
if haskey(dfg.g.factors, factor.label)
8888
error("Factor '$(factor.label)' already exists in the factor graph")

src/services/AbstractDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ Returns a LightDFG{NoSolverParams, DFGVariableSummary, DFGFactorSummary}.
578578
"""
579579
function getSummaryGraph(dfg::G)::LightDFG{NoSolverParams, DFGVariableSummary, DFGFactorSummary} where {G <: AbstractDFG}
580580
summaryDfg = LightDFG{NoSolverParams, DFGVariableSummary, DFGFactorSummary}(
581-
description="Summary of $(dfg.description))",
581+
description="Summary of $(dfg.description)",
582582
userId=dfg.userId,
583583
robotId=dfg.robotId,
584584
sessionId=dfg.sessionId)

0 commit comments

Comments
 (0)