Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 节点对仅连接到子图中的一种类型的节点_Neo4j_Cypher - Fatal编程技术网

Neo4j 节点对仅连接到子图中的一种类型的节点

Neo4j 节点对仅连接到子图中的一种类型的节点,neo4j,cypher,Neo4j,Cypher,我正在努力实现以下目标,但我不太明白如何做到这一点 我有类型为:A,:S1,:S2:t和:k的节点 我想找到一对连接到:A节点的:t节点,它们从未连接到:S或:S1节点,但我想在子图中执行此操作,其中:A,:S和:S1节点连接到另一个节点(:k{t:1}) 如果不需要子图,它非常简单,例如: match p=(n:t)-[]-(:A)-[]-(m:t) WHERE NOT (n)-[]-(:S)-[]-(m) and NOT (n)-[]-(:S1)-[]-(m) WITH n,m,coun

我正在努力实现以下目标,但我不太明白如何做到这一点

我有类型为
:A
:S1
:S2
:t和
:k
的节点

我想找到一对连接到
:A
节点的
:t
节点,它们从未连接到
:S
:S1
节点,但我想在子图中执行此操作,其中
:A
:S
:S1
节点连接到另一个节点
(:k{t:1})

如果不需要子图,它非常简单,例如:

match p=(n:t)-[]-(:A)-[]-(m:t) 
WHERE NOT (n)-[]-(:S)-[]-(m) 
and NOT (n)-[]-(:S1)-[]-(m)
WITH n,m,count(p) as test
where test >4
return n.token,m.token,test ORDER BY test DESC
但是我该怎么把我的钱放进去呢

(:A)--(:k{t:1})


关系?

简单地
首先匹配子图,然后再
匹配所需的n个节点对怎么样

这样:

// First MATCH (:A)--(:k{t:1}), (:S)--(:k{t:1}), (:S1)--(:k{t:1})
// Store the matched nodes in a, k, s and s1 variables
MATCH (a:A)--(k:k{t:1}),
(s:S)--(k),
(s1:S1)--(k)

// Using a, k, s and s1 match couple of n...
// connected with a
MATCH p = (n:t)--(a)--(m:t)
// not connected with s 
WHERE NOT (n)--(s)--(m)
// and not connected with s1
AND NOT (n)--(s1)--(m)
WITH n, m, count(p) as count
WHERE count > 4
RETURN n.token, m.token, count
ORDER BY count

如何简单地将子图先匹配,然后再匹配所需的n个节点

这样:

// First MATCH (:A)--(:k{t:1}), (:S)--(:k{t:1}), (:S1)--(:k{t:1})
// Store the matched nodes in a, k, s and s1 variables
MATCH (a:A)--(k:k{t:1}),
(s:S)--(k),
(s1:S1)--(k)

// Using a, k, s and s1 match couple of n...
// connected with a
MATCH p = (n:t)--(a)--(m:t)
// not connected with s 
WHERE NOT (n)--(s)--(m)
// and not connected with s1
AND NOT (n)--(s1)--(m)
WITH n, m, count(p) as count
WHERE count > 4
RETURN n.token, m.token, count
ORDER BY count