Skip to content

Commit 317fb01

Browse files
committed
Updating CGDFG
1 parent 1d06981 commit 317fb01

File tree

2 files changed

+29
-38
lines changed

2 files changed

+29
-38
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -541,26 +541,16 @@ Delete the referened DFGFactor from the DFG.
541541
"""
542542
deleteFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)::DFGFactor = deleteFactor!(dfg, factor.label)
543543

544-
# Returns a flat vector of the vertices, keyed by ID.
545-
# Assuming only variables here for now - think maybe not, should be variables+factors?
546544
"""
547545
$(SIGNATURES)
548546
List the DFGVariables in the DFG.
549547
Optionally specify a label regular expression to retrieves a subset of the variables.
550548
"""
551-
function ls(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
549+
function getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
552550
variableIds = getVariableIds(dfg, regexFilter)
553551
return map(vId->getVariable(dfg, vId), variableIds)
554552
end
555553

556-
# Alias
557-
"""
558-
$(SIGNATURES)
559-
List the DFGVariables in the DFG.
560-
Optionally specify a label regular expression to retrieves a subset of the variables.
561-
"""
562-
getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable} = ls(dfg, regexFilter)
563-
564554
"""
565555
$(SIGNATURES)
566556
Get a list of IDs of the DFGVariables in the DFG.
@@ -575,32 +565,22 @@ function getVariableIds(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=
575565
end
576566
end
577567

568+
# Alias
578569
"""
579570
$(SIGNATURES)
580-
List the DFGFactors in the DFG.
581-
Optionally specify a label regular expression to retrieves a subset of the factors.
571+
List the DFGVariables in the DFG.
572+
Optionally specify a label regular expression to retrieves a subset of the variables.
582573
"""
583-
function lsf(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
584-
factorIds = getFactorIds(dfg, regexFilter)
585-
return map(vId->getFactor(dfg, vId), factorIds)
586-
end
574+
ls(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getVariableIds(dfg, regexFilter)
587575

588-
# Alias
589576
"""
590577
$(SIGNATURES)
591578
List the DFGFactors in the DFG.
592579
Optionally specify a label regular expression to retrieves a subset of the factors.
593580
"""
594-
getFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor} = lsf(dfg, regexFilter)
595-
596-
# Alias - getNeighbors
597-
#TODO: Refactor this
598-
"""
599-
$(SIGNATURES)
600-
Get neighbors around a given node. TODO: Refactor this
601-
"""
602-
function lsf(dfg::CloudGraphsDFG, label::Symbol)::Vector{Symbol}
603-
return getNeighbors(dfg, label)
581+
function getFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
582+
factorIds = getFactorIds(dfg, regexFilter)
583+
return map(vId->getFactor(dfg, vId), factorIds)
604584
end
605585

606586
"""
@@ -617,6 +597,23 @@ function getFactorIds(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=no
617597
end
618598
end
619599

600+
# Alias
601+
"""
602+
$(SIGNATURES)
603+
List the DFGFactors in the DFG.
604+
Optionally specify a label regular expression to retrieves a subset of the factors.
605+
"""
606+
lsf(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getFactorIds(dfg, regexFilter)
607+
608+
# Alias - getNeighbors
609+
"""
610+
$(SIGNATURES)
611+
Get neighbors around a given node. TODO: Refactor this
612+
"""
613+
function lsf(dfg::CloudGraphsDFG, label::Symbol)::Vector{Symbol}
614+
return getNeighbors(dfg, label)
615+
end
616+
620617
"""
621618
$(SIGNATURES)
622619
Checks if the graph is fully connected, returns true if so.

test/cloudGraphsDFGTests.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Run: sudo docker run --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=neo4j/test neo4j
77

88
using Revise
9+
using Neo4j
910
using DistributedFactorGraphs
1011
using IncrementalInference
1112
using Test
@@ -15,7 +16,7 @@ using RoME
1516
@testset "Setup and clearing the existing graph" begin
1617
# Create connection
1718
# Caching: Off
18-
global cgDFG = CloudGraphsDFG("localhost", 7474, "neo4j", "test",
19+
global cgDFG = CloudGraphsDFG{NoSolverParams}("localhost", 7474, "neo4j", "test",
1920
"testUser", "testRobot", "testSession",
2021
nothing,
2122
nothing,
@@ -92,12 +93,12 @@ end
9293
# Not fast though, TODO: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/39
9394
vars = getVariables(cgDFG)
9495
vars2 = ls(cgDFG)
95-
@test map(v->v.label, vars) == map(v->v.label, vars2)
96+
@test map(v->v.label, vars) == vars2
9697
@test symdiff(map(v->v.label, vars), [:x1, :x2, :x3, :l1, :l2]) == []
9798

9899
facts = getFactors(cgDFG)
99100
facts2 = lsf(cgDFG)
100-
@test map(v->v.label, facts) == map(v->v.label, facts2)
101+
@test map(v->v.label, facts) == facts2
101102
@test symdiff(map(f->f.label, facts), [:x1x2f1, :x1f1, :x2l1f1, :x2x3f1, :x3l2f1, :x1l1f1]) == []
102103

103104
@test symdiff(getNeighbors(cgDFG, :x2), [:x2l1f1, :x2x3f1, :x1x2f1]) == []
@@ -168,13 +169,6 @@ end
168169
# clearSession!!(cgDFGCopy)
169170
end
170171

171-
global cgDFG = CloudGraphsDFG("localhost", 7474, "neo4j", "test",
172-
"testUser", "testRobot", "testSession",
173-
nothing,
174-
nothing,
175-
IncrementalInference.decodePackedType)
176-
177-
178172
@testset "getAdjacencyMatrix test" begin
179173
adjMat = getAdjacencyMatrix(cgDFG)
180174
# Note that by this point, :x3 is bound to :x1x2f1, which is counterintuitive but that's tests for you

0 commit comments

Comments
 (0)