41
41
$(SIGNATURES)
42
42
Create a new CloudGraphs-based DFG factor graph using a Neo4j.Connection.
43
43
"""
44
- function CloudGraphsDFG (neo4jConnection:: Neo4j.Connection , userId:: String , robotId:: String , sessionId:: String , encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description:: String = " CloudGraphs DFG" , solverParams:: Any = nothing , useCache:: Bool = false )
44
+ function CloudGraphsDFG {T} (neo4jConnection:: Neo4j.Connection , userId:: String , robotId:: String , sessionId:: String , encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description:: String = " CloudGraphs DFG" , solverParams:: T = NoSolverParams () , useCache:: Bool = false ) where T <: AbstractParams
45
45
graph = Neo4j. getgraph (neo4jConnection)
46
46
neo4jInstance = Neo4jInstance (neo4jConnection, graph)
47
- return CloudGraphsDFG (neo4jInstance, description, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, Dict {Symbol, Int64} (), Dict {Symbol, DFGVariable} (), Dict {Symbol, DFGFactor} (), Symbol[], solverParams, useCache)
47
+ return CloudGraphsDFG {T} (neo4jInstance, description, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, Dict {Symbol, Int64} (), Dict {Symbol, DFGVariable} (), Dict {Symbol, DFGFactor} (), Symbol[], solverParams, useCache)
48
48
end
49
49
"""
50
50
$(SIGNATURES)
51
51
Create a new CloudGraphs-based DFG factor graph by specifying the Neo4j connection information.
52
52
"""
53
- function CloudGraphsDFG (host:: String , port:: Int , dbUser:: String , dbPassword:: String , userId:: String , robotId:: String , sessionId:: String , encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description:: String = " CloudGraphs DFG" , solverParams:: Any = nothing , useCache:: Bool = false )
53
+ function CloudGraphsDFG {T} (host:: String , port:: Int , dbUser:: String , dbPassword:: String , userId:: String , robotId:: String , sessionId:: String , encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc; description:: String = " CloudGraphs DFG" , solverParams:: T = NoSolverParams () , useCache:: Bool = false ) where T <: AbstractParams
54
54
neo4jConnection = Neo4j. Connection (host, port= port, user= dbUser, password= dbPassword);
55
- return CloudGraphsDFG (neo4jConnection, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, description= description, solverParams= solverParams, useCache= useCache)
55
+ return CloudGraphsDFG {T} (neo4jConnection, userId, robotId, sessionId, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, description= description, solverParams= solverParams, useCache= useCache)
56
56
end
57
57
58
58
"""
@@ -68,7 +68,7 @@ function _getDuplicatedEmptyDFG(dfg::CloudGraphsDFG)::CloudGraphsDFG
68
68
length (_getLabelsFromCyphonQuery (dfg. neo4jInstance, " (node:$(dfg. userId) :$(dfg. robotId) :$(sessionId) )" )) == 0 && break
69
69
end
70
70
@debug " Unique+empty copy session name: $sessionId "
71
- return CloudGraphsDFG (dfg. neo4jInstance. connection, dfg. userId, dfg. robotId, sessionId, dfg. encodePackedTypeFunc, dfg. getPackedTypeFunc, dfg. decodePackedTypeFunc, solverParams= deepcopy (dfg. solverParams), description= " (Copy of) $(dfg. description) " , useCache= dfg. useCache)
71
+ return CloudGraphsDFG {typeof(dfg.solverParams)} (dfg. neo4jInstance. connection, dfg. userId, dfg. robotId, sessionId, dfg. encodePackedTypeFunc, dfg. getPackedTypeFunc, dfg. decodePackedTypeFunc, solverParams= deepcopy (dfg. solverParams), description= " (Copy of) $(dfg. description) " , useCache= dfg. useCache)
72
72
end
73
73
74
74
# Accessors
@@ -77,7 +77,9 @@ getDescription(dfg::CloudGraphsDFG) = dfg.description
77
77
setDescription (dfg:: CloudGraphsDFG , description:: String ) = dfg. description = description
78
78
getAddHistory (dfg:: CloudGraphsDFG ) = dfg. addHistory
79
79
getSolverParams (dfg:: CloudGraphsDFG ) = dfg. solverParams
80
- setSolverParams (dfg:: CloudGraphsDFG , solverParams:: Any ) = dfg. solverParams = solverParams
80
+ function setSolverParams (dfg:: CloudGraphsDFG , solverParams:: T ) where T <: AbstractParams
81
+ dfg. solverParams = solverParams
82
+ end
81
83
82
84
"""
83
85
$(SIGNATURES)
@@ -440,16 +442,12 @@ function updateFactor!(dfg::CloudGraphsDFG, variables::Vector{DFGVariable}, fact
440
442
# Update the body
441
443
factor = updateFactor! (dfg, factor)
442
444
443
- @show " HERE WITH $(factor. label) !"
444
- @show map (v-> v. label, variables)
445
-
446
445
# Now update the relationships
447
- @show existingNeighbors = getNeighbors (dfg, factor)
446
+ existingNeighbors = getNeighbors (dfg, factor)
448
447
if symdiff (existingNeighbors, map (v-> v. label, variables)) == []
449
448
# Done, otherwise we need to remake the edges.
450
449
return factor
451
450
end
452
- @show " HERE WITH $(factor. label) !"
453
451
# Delete existing relationships
454
452
fNode = Neo4j. getnode (dfg. neo4jInstance. graph, factor. _internalId)
455
453
for relationship in Neo4j. getrels (fNode)
@@ -707,39 +705,8 @@ function ls(dfg::CloudGraphsDFG, label::Symbol)::Vector{Symbol} where T <: DFGNo
707
705
return getNeighbors (dfg, label)
708
706
end
709
707
710
- function _copyIntoGraph! (sourceDFG:: CloudGraphsDFG , destDFG:: CloudGraphsDFG , variableFactorLabels:: Vector{Symbol} , includeOrphanFactors:: Bool = false ):: Nothing
711
- @show variableFactorLabels
712
- # Split into variables and factors
713
- sourceVariables = map (vId-> getVariable (sourceDFG, vId), intersect (getVariableIds (sourceDFG), variableFactorLabels))
714
- sourceFactors = map (fId-> getFactor (sourceDFG, fId), intersect (getFactorIds (sourceDFG), variableFactorLabels))
715
- if length (sourceVariables) + length (sourceFactors) != length (variableFactorLabels)
716
- rem = symdiff (map (v-> v. label, sourceVariables), variableFactorLabels)
717
- rem = symdiff (map (f-> f. label, sourceFactors), variableFactorLabels)
718
- error (" Cannot copy because cannot find the following nodes in the source graph: $rem " )
719
- end
720
-
721
- # Now we have to add all variables first,
722
- for variable in sourceVariables
723
- addVariable! (destDFG, deepcopy (variable))
724
- end
725
- # And then all factors to the destDFG.
726
- for factor in sourceFactors
727
- # Get the original factor variables (we need them to create it)
728
- sourceFactorVariableIds = getNeighbors (sourceDFG, factor)
729
- # Find the labels and associated variables in our new subgraph
730
- factVariableIds = Symbol[]
731
- for variable in sourceFactorVariableIds
732
- if exists (destDFG, variable)
733
- push! (factVariableIds, variable)
734
- end
735
- end
736
- # Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
737
- if includeOrphanFactors || length (factVariableIds) == length (sourceFactorVariableIds)
738
- addFactor! (destDFG, factVariableIds, deepcopy (factor))
739
- end
740
- end
741
- return nothing
742
- end
708
+ # # This is moved to services/AbstractDFG.jl
709
+ # function _copyIntoGraph!(sourceDFG::CloudGraphsDFG, destDFG::CloudGraphsDFG, variableFactorLabels::Vector{Symbol}, includeOrphanFactors::Bool=false)::Nothing
743
710
744
711
"""
745
712
$(SIGNATURES)
@@ -809,8 +776,8 @@ function getAdjacencyMatrix(dfg::CloudGraphsDFG)::Matrix{Union{Nothing, Symbol}}
809
776
error (string (nodes. errors))
810
777
end
811
778
# Add in the relationships
812
- @show varRel = Symbol .(map (node -> node[" row" ][1 ], nodes. results[1 ][" data" ]))
813
- @show factRel = Symbol .(map (node -> node[" row" ][2 ], nodes. results[1 ][" data" ]))
779
+ varRel = Symbol .(map (node -> node[" row" ][1 ], nodes. results[1 ][" data" ]))
780
+ factRel = Symbol .(map (node -> node[" row" ][2 ], nodes. results[1 ][" data" ]))
814
781
for i = 1 : length (varRel)
815
782
adjMat[fDict[factRel[i]], vDict[varRel[i]]] = factRel[i]
816
783
end
0 commit comments