在单个查询中计算入度和出度
Calculating In Degree and Out Degree in a single query
我可以使用以下查询 "In Degree" 成功:
match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree
我可以使用以下查询 "Out Degree" 成功:
match a=(p:Person)<--(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as Out_Degree
但是当我将两者合并并编写如下查询时,Cypher 给出的结果是 "Out Degree"。
match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'}),b=(r:Person)<--(s:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree, count(b) as Out_Degree
我是不是漏掉了什么?有人可以帮我解决这个问题吗?
你能试试这个查询吗:
MATCH (p:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN size((p)<--(:Person)) AS In_Degree, size((p)-->(:Person)) AS Out_Degree
干杯。
我可以使用以下查询 "In Degree" 成功:
match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree
我可以使用以下查询 "Out Degree" 成功:
match a=(p:Person)<--(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as Out_Degree
但是当我将两者合并并编写如下查询时,Cypher 给出的结果是 "Out Degree"。
match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'}),b=(r:Person)<--(s:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree, count(b) as Out_Degree
我是不是漏掉了什么?有人可以帮我解决这个问题吗?
你能试试这个查询吗:
MATCH (p:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN size((p)<--(:Person)) AS In_Degree, size((p)-->(:Person)) AS Out_Degree
干杯。