Skip to content

Commit 37bb5f4

Browse files
authored
Merge pull request #427 from JuliaRobotics/maint/20Q2/isConnected
Rename hasOrphans and isFullyConnected to isConnected
2 parents fde1bf6 + 29b6e7e commit 37bb5f4

File tree

11 files changed

+27
-35
lines changed

11 files changed

+27
-35
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ function listFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=not
375375
end
376376
end
377377

378-
function isFullyConnected(dfg::CloudGraphsDFG)::Bool
378+
function isConnected(dfg::CloudGraphsDFG)::Bool
379379
# If the total number of nodes == total number of distinct connected nodes, then it is fully connected
380380
# Total nodes
381381
varIds = listVariables(dfg)

src/Deprecated.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ function Base.convert(::Type{SkeletonDFGFactor}, f::FactorDataLevel1)
106106
return SkeletonDFGFactor(f)
107107
end
108108

109+
110+
@deprecate hasOrphans(dfg) !isConnected(dfg)
111+
@deprecate isFullyConnected(dfg) isConnected(dfg)
112+
109113
##==============================================================================
110114
## WIP on consolidated subgraph functions, aim to remove in 0.8
111115
##==============================================================================

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export exists,
7171
getVariables, getFactors,
7272
isVariable, isFactor
7373

74-
export isFullyConnected, hasOrphans
74+
export isConnected
7575

7676
export getBiadjacencyMatrix
7777

src/GraphsDFG/GraphsDFG.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
3535
getFactors,
3636
listFactors,
3737
lsf,
38-
isFullyConnected,
39-
hasOrphans,
38+
isConnected,
4039
getNeighbors,
4140
buildSubgraph,
4241
copyGraph!,

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing;
220220
return factors
221221
end
222222

223-
function isFullyConnected(dfg::GraphsDFG)::Bool
223+
function isConnected(dfg::GraphsDFG)::Bool
224224
return length(Graphs.connected_components(dfg.g)) == 1
225225
end
226226

src/LightDFG/LightDFG.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
3737
getFactors,
3838
listFactors,
3939
lsf,
40-
isFullyConnected,
41-
hasOrphans,
40+
isConnected,
4241
getNeighbors,
4342
buildSubgraph,
4443
copyGraph!,

src/LightDFG/services/LightDFG.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ function listFactors(dfg::LightDFG, regexFilter::Union{Nothing, Regex}=nothing;
210210
return factors
211211
end
212212

213-
function isFullyConnected(dfg::LightDFG)::Bool
214-
return length(LightGraphs.connected_components(dfg.g)) == 1
213+
function isConnected(dfg::LightDFG)::Bool
214+
return LightGraphs.is_connected(dfg.g)
215+
# return length(LightGraphs.connected_components(dfg.g)) == 1
215216
end
216217

217218
function _isSolvable(dfg::LightDFG, label::Symbol, ready::Int)::Bool

src/services/AbstractDFG.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ end
292292
$(SIGNATURES)
293293
Checks if the graph is fully connected, returns true if so.
294294
"""
295-
function isFullyConnected(dfg::AbstractDFG)::Bool
296-
error("isFullyConnected not implemented for $(typeof(dfg))")
295+
function isConnected(dfg::AbstractDFG)::Bool
296+
error("isConnected not implemented for $(typeof(dfg))")
297297
end
298298

299299
"""
@@ -418,15 +418,6 @@ function getNeighbors(dfg::AbstractDFG, node::DFGNode; solvable::Int=0)::Vector{
418418
getNeighbors(dfg, node.label, solvable=solvable)
419419
end
420420

421-
#Alias
422-
#TODO rather actually check if there are orphaned factors (factors without all variables)
423-
"""
424-
$(SIGNATURES)
425-
Checks if the graph is not fully connected, returns true if it is not contiguous.
426-
"""
427-
function hasOrphans(dfg::G)::Bool where G <: AbstractDFG
428-
return !isFullyConnected(dfg)
429-
end
430421

431422
##==============================================================================
432423
## Listing and listing aliases

test/iifInterfaceTests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ end
324324
# Connectivity test
325325
@testset "Connectivity Test" begin
326326
global dfg,v1,v2,f1
327-
@test isFullyConnected(dfg) == true
328-
@test hasOrphans(dfg) == false
327+
@test isConnected(dfg) == true
328+
@test @test_deprecated isFullyConnected(dfg) == true
329+
@test @test_deprecated hasOrphans(dfg) == false
329330
addVariable!(dfg, :orphan, ContinuousScalar, labels = [:POSE], solvable=0)
330-
@test isFullyConnected(dfg) == false
331-
@test hasOrphans(dfg) == true
331+
@test isConnected(dfg) == false
332332
end
333333

334334
# Adjacency matrices

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct NotImplementedDFG <: AbstractDFG end
178178
@test_throws ErrorException deleteFactor!(dfg, :a)
179179
@test_throws ErrorException getVariables(dfg)
180180
@test_throws ErrorException getFactors(dfg)
181-
@test_throws ErrorException isFullyConnected(dfg)
181+
@test_throws ErrorException isConnected(dfg)
182182
@test_throws ErrorException getNeighbors(dfg, v1)
183183
@test_throws ErrorException getNeighbors(dfg, :a)
184184

0 commit comments

Comments
 (0)