Skip to content

Commit 5d6a35f

Browse files
authored
Merge pull request #1024 from JuliaRobotics/23Q3/maint/listNeighbors
Deprecate getNeighbors for listNeighbors
2 parents 311fa2a + 132f95b commit 5d6a35f

File tree

11 files changed

+52
-46
lines changed

11 files changed

+52
-46
lines changed

docs/src/BuildingGraphs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ To list all variables or factors (instead of just their labels), use the
115115

116116
Traversing and Querying functions for finding the relationships and building subtraphs include:
117117

118-
- [`getNeighbors`](@ref)
118+
- [`listNeighbors`](@ref)
119119
- [`buildSubgraph`](@ref)
120120
- [`getBiadjacencyMatrix`](@ref)
121121

src/Deprecated.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
## ================================================================================
3+
## Remove in v0.24
4+
##=================================================================================
5+
#NOTE free up getNeighbors to return the variables or factors
6+
@deprecate getNeighbors(args...; kwargs...) listNeighbors(args...; kwargs...)
7+
28

39
## ================================================================================
410
## Remove in v0.23

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export packVariableNodeData, unpackVariableNodeData
199199

200200
export getSolvedCount, isSolved, setSolvedCount!, isInitialized, isMarginalized, setMarginalized!
201201

202-
export getNeighborhood, getNeighbors, _getDuplicatedEmptyDFG
202+
export getNeighborhood, listNeighbors, _getDuplicatedEmptyDFG
203203
export findFactorsBetweenNaive
204204
export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph!
205205

src/GraphsDFG/GraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
3939
listFactors,
4040
lsf,
4141
isConnected,
42-
getNeighbors,
42+
listNeighbors,
4343
buildSubgraph,
4444
copyGraph!,
4545
getBiadjacencyMatrix,

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function deleteVariable!(dfg::GraphsDFG, label::Symbol)#::Tuple{AbstractDFGVaria
138138

139139
deleteNeighbors = true # reserved, orphaned factors are not supported at this time
140140
if deleteNeighbors
141-
neigfacs = map(l->deleteFactor!(dfg, l), getNeighbors(dfg, label))
141+
neigfacs = map(l->deleteFactor!(dfg, l), listNeighbors(dfg, label))
142142
end
143143
variable = dfg.g.variables[label]
144144
rem_vertex!(dfg.g, dfg.g.labels[label])
@@ -231,7 +231,7 @@ function _isSolvable(dfg::GraphsDFG, label::Symbol, ready::Int)::Bool
231231
return false
232232
end
233233

234-
function getNeighbors(dfg::GraphsDFG, node::DFGNode; solvable::Int=0)
234+
function listNeighbors(dfg::GraphsDFG, node::DFGNode; solvable::Int=0)
235235
label = node.label
236236
if !exists(dfg, label)
237237
error("Variable/factor with label '$(node.label)' does not exist in the factor graph")
@@ -252,7 +252,7 @@ function getNeighbors(dfg::GraphsDFG, node::DFGNode; solvable::Int=0)
252252
end
253253

254254

255-
function getNeighbors(dfg::GraphsDFG, label::Symbol; solvable::Int=0)::Vector{Symbol}
255+
function listNeighbors(dfg::GraphsDFG, label::Symbol; solvable::Int=0)::Vector{Symbol}
256256
if !exists(dfg, label)
257257
error("Variable/factor with label '$(label)' does not exist in the factor graph")
258258
end

src/entities/DFGFactor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Base.@kwdef struct DFGFactorSummary <: AbstractDFGFactor
232232
"""Factor tags, e.g [:FACTOR].
233233
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
234234
tags::Set{Symbol}
235-
"""Internal cache of the ordering of the neighbor variables. Rather use getNeighbors to get the list as this is an internal value.
235+
"""Internal cache of the ordering of the neighbor variables. Rather use listNeighbors to get the list as this is an internal value.
236236
Accessors: [`getVariableOrder`](@ref)"""
237237
_variableOrderSymbols::Vector{Symbol}
238238
"""Variable timestamp.
@@ -261,7 +261,7 @@ Base.@kwdef struct SkeletonDFGFactor <: AbstractDFGFactor
261261
"""Factor tags, e.g [:FACTOR].
262262
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
263263
tags::Set{Symbol}
264-
"""Internal cache of the ordering of the neighbor variables. Rather use getNeighbors to get the list as this is an internal value.
264+
"""Internal cache of the ordering of the neighbor variables. Rather use listNeighbors to get the list as this is an internal value.
265265
Accessors: [`getVariableOrder`](@ref)"""
266266
_variableOrderSymbols::Vector{Symbol}
267267
end

src/services/AbstractDFG.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ end
365365
$(SIGNATURES)
366366
Retrieve a list of labels of the immediate neighbors around a given variable or factor specified by its label.
367367
"""
368-
function getNeighbors(dfg::AbstractDFG, label::Symbol; solvable::Int=0)
369-
error("getNeighbors not implemented for $(typeof(dfg))")
368+
function listNeighbors(dfg::AbstractDFG, label::Symbol; solvable::Int=0)
369+
error("listNeighbors not implemented for $(typeof(dfg))")
370370
end
371371

372372

@@ -479,8 +479,8 @@ end
479479
## Connectivity Alias
480480
##------------------------------------------------------------------------------
481481

482-
function getNeighbors(dfg::AbstractDFG, node::DFGNode; solvable::Int=0)
483-
getNeighbors(dfg, node.label, solvable=solvable)
482+
function listNeighbors(dfg::AbstractDFG, node::DFGNode; solvable::Int=0)
483+
listNeighbors(dfg, node.label; solvable)
484484
end
485485

486486

@@ -621,14 +621,14 @@ end
621621
Retrieve a list of labels of the immediate neighbors around a given variable or factor.
622622
"""
623623
function ls(dfg::G, node::T; solvable::Int=0) where {G <: AbstractDFG, T <: DFGNode}
624-
return getNeighbors(dfg, node, solvable=solvable)
624+
return listNeighbors(dfg, node, solvable=solvable)
625625
end
626626
function ls(dfg::G, label::Symbol; solvable::Int=0) where G <: AbstractDFG
627-
return getNeighbors(dfg, label, solvable=solvable)
627+
return listNeighbors(dfg, label, solvable=solvable)
628628
end
629629

630630
function lsf(dfg::G, label::Symbol; solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
631-
return getNeighbors(dfg, label, solvable=solvable)
631+
return listNeighbors(dfg, label, solvable=solvable)
632632
end
633633

634634
## list by types
@@ -1146,7 +1146,7 @@ function getNeighborhood(dfg::AbstractDFG, label::Symbol, distance::Int)
11461146
for dist in 1:distance
11471147
newNeighbors = Set{Symbol}()
11481148
for node in curList
1149-
neighbors = getNeighbors(dfg, node)
1149+
neighbors = listNeighbors(dfg, node)
11501150
for neighbor in neighbors
11511151
push!(neighborList, neighbor)
11521152
push!(newNeighbors, neighbor)
@@ -1313,7 +1313,7 @@ function getAdjacencyMatrixSymbols(dfg::AbstractDFG; solvable::Int=0)
13131313
adjMat[2:end, 1] = factLabels
13141314
adjMat[1, 2:end] = varLabels
13151315
for (fIndex, factLabel) in enumerate(factLabels)
1316-
factVars = getNeighbors(dfg, getFactor(dfg, factLabel), solvable=solvable)
1316+
factVars = listNeighbors(dfg, getFactor(dfg, factLabel), solvable=solvable)
13171317
map(vLabel -> adjMat[fIndex+1,vDict[vLabel]] = factLabel, factVars)
13181318
end
13191319
return adjMat
@@ -1341,7 +1341,7 @@ function getBiadjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)
13411341
adjMat = spzeros(Int, length(factLabels), length(varLabels))
13421342

13431343
for (fIndex, factLabel) in enumerate(factLabels)
1344-
factVars = getNeighbors(dfg, getFactor(dfg, factLabel), solvable=solvable)
1344+
factVars = listNeighbors(dfg, getFactor(dfg, factLabel), solvable=solvable)
13451345
map(vLabel -> adjMat[fIndex,vDict[vLabel]] = 1, factVars)
13461346
end
13471347
return (B=adjMat, varLabels=varLabels, facLabels=factLabels)
@@ -1426,7 +1426,7 @@ function getSummaryGraph(dfg::G) where {G <: AbstractDFG}
14261426
# newV = addVariable!(summaryDfg, DFGVariableSummary(v))
14271427
# end
14281428
# for f in getFactors(dfg)
1429-
# addFactor!(summaryDfg, getNeighbors(dfg, f), DFGFactorSummary(f))
1429+
# addFactor!(summaryDfg, listNeighbors(dfg, f), DFGFactorSummary(f))
14301430
# end
14311431
return summaryDfg
14321432
end

src/services/DFGFactor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ end
115115
$SIGNATURES
116116
117117
Get the variable ordering for this factor.
118-
Should be equivalent to getNeighbors unless something was deleted in the graph.
118+
Should be equivalent to listNeighbors unless something was deleted in the graph.
119119
"""
120120
getVariableOrder(fct::DFGFactor) = fct._variableOrderSymbols::Vector{Symbol}
121121
getVariableOrder(dfg::AbstractDFG, fct::Symbol) = getVariableOrder(getFactor(dfg, fct))

test/iifInterfaceTests.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,22 @@ facts = map(n ->
401401
# Trivial test to validate that intersect([], []) returns order of first parameter
402402
@test intersect([:x3, :x2, :x1], [:x1, :x2]) == [:x2, :x1]
403403
# Get neighbors tests
404-
@test getNeighbors(dfg, verts[1]) == [:x1x2f1]
405-
neighbors = getNeighbors(dfg, getFactor(dfg, :x1x2f1))
404+
@test listNeighbors(dfg, verts[1]) == [:x1x2f1]
405+
neighbors = listNeighbors(dfg, getFactor(dfg, :x1x2f1))
406406
@test neighbors == [:x1, :x2]
407407
# Testing aliases
408-
@test getNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1))
409-
@test getNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1)
408+
@test listNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1))
409+
@test listNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1)
410410

411411
# solvable checks
412-
@test getNeighbors(dfg, :x5, solvable=1) == Symbol[]
413-
@test symdiff(getNeighbors(dfg, :x5, solvable=0), [:x4x5f1,:x5x6f1]) == []
414-
@test symdiff(getNeighbors(dfg, :x5),[:x4x5f1,:x5x6f1]) == []
415-
@test getNeighbors(dfg, :x7x8f1, solvable=0) == [:x7, :x8]
416-
@test getNeighbors(dfg, :x7x8f1, solvable=1) == [:x7]
417-
@test getNeighbors(dfg, verts[1], solvable=0) == [:x1x2f1]
418-
@test getNeighbors(dfg, verts[1], solvable=1) == Symbol[]
419-
@test getNeighbors(dfg, verts[1]) == [:x1x2f1]
412+
@test listNeighbors(dfg, :x5, solvable=1) == Symbol[]
413+
@test symdiff(listNeighbors(dfg, :x5, solvable=0), [:x4x5f1,:x5x6f1]) == []
414+
@test symdiff(listNeighbors(dfg, :x5),[:x4x5f1,:x5x6f1]) == []
415+
@test listNeighbors(dfg, :x7x8f1, solvable=0) == [:x7, :x8]
416+
@test listNeighbors(dfg, :x7x8f1, solvable=1) == [:x7]
417+
@test listNeighbors(dfg, verts[1], solvable=0) == [:x1x2f1]
418+
@test listNeighbors(dfg, verts[1], solvable=1) == Symbol[]
419+
@test listNeighbors(dfg, verts[1]) == [:x1x2f1]
420420

421421
end
422422

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ struct NotImplementedDFG{T} <: AbstractDFG{T} end
131131
@test_throws ErrorException getVariables(dfg)
132132
@test_throws ErrorException getFactors(dfg)
133133
@test_throws ErrorException isConnected(dfg)
134-
@test_throws ErrorException getNeighbors(dfg, v1)
135-
@test_throws ErrorException getNeighbors(dfg, :a)
134+
@test_throws ErrorException listNeighbors(dfg, v1)
135+
@test_throws ErrorException listNeighbors(dfg, :a)
136136

137137
@test_throws ErrorException _getDuplicatedEmptyDFG(dfg)
138138

0 commit comments

Comments
 (0)