@@ -418,24 +418,25 @@ function listFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=not
418
418
end
419
419
420
420
function isConnected (dfg:: CloudGraphsDFG ):: Bool
421
- # If the total number of nodes == total number of distinct connected nodes, then it is fully connected
422
- # Total nodes
423
- varIds = listVariables (dfg)
424
- factIds = listFactors (dfg)
425
- length (varIds) + length (factIds) == 0 && return false
426
-
427
- # Total distinct connected nodes - thank you Neo4j for 0..* awesomeness!!
428
- # TODO : Deprecated matching technique and it's technically an expensive call - optimize.
429
- query = """
430
- match (n:$(dfg. userId) :$(dfg. robotId) :$(dfg. sessionId) :$(varIds[1 ]) )-[FACTORGRAPH*]-(node:$(dfg. userId) :$(dfg. robotId) :$(dfg. sessionId) )
431
- WHERE (n:VARIABLE OR n:FACTOR OR node:VARIABLE OR node:FACTOR) and not (node:SESSION or n:SESSION) and not (n:PPE) and not (node:PPE)
432
- WITH collect(n)+collect(node) as nodelist
433
- unwind nodelist as nodes
434
- return count(distinct nodes)"""
435
- @debug " [Query] $query "
436
- result = _queryNeo4j (dfg. neo4jInstance, query)
437
- # Neo4j.jl data structure sometimes feels brittle... like below
438
- return result. results[1 ][" data" ][1 ][" row" ][1 ] == length (varIds) + length (factIds)
421
+ # # If the total number of nodes == total number of distinct connected nodes, then it is fully connected
422
+ # # Total nodes
423
+ # varIds = listVariables(dfg)
424
+ # factIds = listFactors(dfg)
425
+ # length(varIds) + length(factIds) == 0 && return false
426
+
427
+ # # Total distinct connected nodes - thank you Neo4j for 0..* awesomeness!!
428
+ # # TODO : Deprecated matching technique and it's technically an expensive call - optimize.
429
+ # query = """
430
+ # match (n:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId):$(varIds[1]))-[FACTORGRAPH*]-(node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId))
431
+ # WHERE (n:VARIABLE OR n:FACTOR OR node:VARIABLE OR node:FACTOR) and not (node:SESSION or n:SESSION) and not (n:PPE) and not (node:PPE)
432
+ # WITH collect(n)+collect(node) as nodelist
433
+ # unwind nodelist as nodes
434
+ # return count(distinct nodes)"""
435
+ # @debug "[Query] $query"
436
+ # result = _queryNeo4j(dfg.neo4jInstance, query)
437
+ # # Neo4j.jl data structure sometimes feels brittle... like below
438
+ # return result.results[1]["data"][1]["row"][1] == length(varIds) + length(factIds)
439
+ return isConnected (SkeletonDFG (dfg))
439
440
end
440
441
441
442
function getNeighbors (dfg:: CloudGraphsDFG , node:: T ; solvable:: Int = 0 ):: Vector{Symbol} where T <: DFGNode
@@ -943,3 +944,28 @@ function emptyTags!(dfg::CloudGraphsDFG, sym::Symbol)
943
944
return getTags (getNode (dfg, sym))
944
945
945
946
end
947
+
948
+
949
+ # #==============================================================================
950
+ # # Skeleton DFG Constructor
951
+ # #==============================================================================
952
+ # TODO tags
953
+ function _getSkeletonFactors (dfg:: CloudGraphsDFG )
954
+ neo4jInstance = dfg. neo4jInstance
955
+ query = " match (node:$(join (_getLabelsForType (dfg, DFGFactor),' :' )) ) return distinct(node.label),node._variableOrderSymbols"
956
+ result = _queryNeo4j (neo4jInstance, query)
957
+ facs = map (node -> SkeletonDFGFactor (Symbol (node[" row" ][1 ]),Symbol .(node[" row" ][2 ])), result. results[1 ][" data" ])
958
+ return facs
959
+ end
960
+ # TODO tags
961
+ function _getSkeletonVariables (dfg:: CloudGraphsDFG )
962
+ return SkeletonDFGVariable .(ls (dfg))
963
+ end
964
+
965
+ export SkeletonDFG
966
+ function SkeletonDFG (cfg:: CloudGraphsDFG )
967
+ sfg = LightDFG {NoSolverParams, SkeletonDFGVariable, SkeletonDFGFactor} ()
968
+ addVariable! .(sfg, _getSkeletonVariables (cfg))
969
+ addFactor! .(sfg, _getSkeletonFactors (cfg))
970
+ return sfg
971
+ end
0 commit comments