Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename hasOrphans and isFullyConnected to isConnected #427

Merged
merged 1 commit into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CloudGraphsDFG/services/CloudGraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function listFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=not
end
end

function isFullyConnected(dfg::CloudGraphsDFG)::Bool
function isConnected(dfg::CloudGraphsDFG)::Bool
# If the total number of nodes == total number of distinct connected nodes, then it is fully connected
# Total nodes
varIds = listVariables(dfg)
Expand Down
4 changes: 4 additions & 0 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ function Base.convert(::Type{SkeletonDFGFactor}, f::FactorDataLevel1)
return SkeletonDFGFactor(f)
end


@deprecate hasOrphans(dfg) !isConnected(dfg)
@deprecate isFullyConnected(dfg) isConnected(dfg)

##==============================================================================
## WIP on consolidated subgraph functions, aim to remove in 0.8
##==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export exists,
getVariables, getFactors,
isVariable, isFactor

export isFullyConnected, hasOrphans
export isConnected

export getBiadjacencyMatrix

Expand Down
3 changes: 1 addition & 2 deletions src/GraphsDFG/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
getFactors,
listFactors,
lsf,
isFullyConnected,
hasOrphans,
isConnected,
getNeighbors,
buildSubgraph,
copyGraph!,
Expand Down
2 changes: 1 addition & 1 deletion src/GraphsDFG/services/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing;
return factors
end

function isFullyConnected(dfg::GraphsDFG)::Bool
function isConnected(dfg::GraphsDFG)::Bool
return length(Graphs.connected_components(dfg.g)) == 1
end

Expand Down
3 changes: 1 addition & 2 deletions src/LightDFG/LightDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ import ...DistributedFactorGraphs: setSolverParams!,
getFactors,
listFactors,
lsf,
isFullyConnected,
hasOrphans,
isConnected,
getNeighbors,
buildSubgraph,
copyGraph!,
Expand Down
5 changes: 3 additions & 2 deletions src/LightDFG/services/LightDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ function listFactors(dfg::LightDFG, regexFilter::Union{Nothing, Regex}=nothing;
return factors
end

function isFullyConnected(dfg::LightDFG)::Bool
return length(LightGraphs.connected_components(dfg.g)) == 1
function isConnected(dfg::LightDFG)::Bool
return LightGraphs.is_connected(dfg.g)
# return length(LightGraphs.connected_components(dfg.g)) == 1
end

function _isSolvable(dfg::LightDFG, label::Symbol, ready::Int)::Bool
Expand Down
13 changes: 2 additions & 11 deletions src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ end
$(SIGNATURES)
Checks if the graph is fully connected, returns true if so.
"""
function isFullyConnected(dfg::AbstractDFG)::Bool
error("isFullyConnected not implemented for $(typeof(dfg))")
function isConnected(dfg::AbstractDFG)::Bool
error("isConnected not implemented for $(typeof(dfg))")
end

"""
Expand Down Expand Up @@ -418,15 +418,6 @@ function getNeighbors(dfg::AbstractDFG, node::DFGNode; solvable::Int=0)::Vector{
getNeighbors(dfg, node.label, solvable=solvable)
end

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

##==============================================================================
## Listing and listing aliases
Expand Down
8 changes: 4 additions & 4 deletions test/iifInterfaceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ end
# Connectivity test
@testset "Connectivity Test" begin
global dfg,v1,v2,f1
@test isFullyConnected(dfg) == true
@test hasOrphans(dfg) == false
@test isConnected(dfg) == true
@test @test_deprecated isFullyConnected(dfg) == true
@test @test_deprecated hasOrphans(dfg) == false
addVariable!(dfg, :orphan, ContinuousScalar, labels = [:POSE], solvable=0)
@test isFullyConnected(dfg) == false
@test hasOrphans(dfg) == true
@test isConnected(dfg) == false
end

# Adjacency matrices
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct NotImplementedDFG <: AbstractDFG end
@test_throws ErrorException deleteFactor!(dfg, :a)
@test_throws ErrorException getVariables(dfg)
@test_throws ErrorException getFactors(dfg)
@test_throws ErrorException isFullyConnected(dfg)
@test_throws ErrorException isConnected(dfg)
@test_throws ErrorException getNeighbors(dfg, v1)
@test_throws ErrorException getNeighbors(dfg, :a)

Expand Down
18 changes: 8 additions & 10 deletions test/testBlocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1204,21 +1204,19 @@ end

function ConnectivityTest(testDFGAPI; kwargs...)
dfg, verts, facs = connectivityTestGraph(testDFGAPI; kwargs...)
@test isFullyConnected(dfg) == true
@test hasOrphans(dfg) == false
@test isConnected(dfg) == true
@test @test_deprecated isFullyConnected(dfg) == true
@test @test_deprecated hasOrphans(dfg) == false

deleteFactor!(dfg, :x9x10f1)
@test isFullyConnected(dfg) == false
@test hasOrphans(dfg) == true
@test isConnected(dfg) == false

deleteVariable!(dfg, :x5)
if testDFGAPI == GraphsDFG
@error "FIXME: isFullyConnected is partially broken for GraphsDFG see #286"
@test_broken isFullyConnected(dfg) == false
@test_broken hasOrphans(dfg) == true
@error "FIXME: isConnected is partially broken for GraphsDFG see #286"
@test_broken isConnected(dfg) == false
else
@test isFullyConnected(dfg) == false
@test hasOrphans(dfg) == true
@test isConnected(dfg) == false
end
end

Expand Down Expand Up @@ -1256,7 +1254,7 @@ function CopyFunctionsTest(testDFGAPI; kwargs...)
dcdfg_part = deepcopyGraph(LightDFG, dfg, vlbls, flbls)
@test issetequal(ls(dcdfg_part), vlbls)
@test issetequal(lsf(dcdfg_part), flbls)
@test !isFullyConnected(dcdfg_part)
@test !isConnected(dcdfg_part)
# dfgplot(dcdfg_part)


Expand Down