3
有沒有辦法在neo4j 1.9.7中執行只返回基數爲1的輸出關係的密碼查詢?Cypher關係基數
e.g
N2 ----> N4 -----> N10
| |-------> N9
|
|------> N5 -----> N9
|
|------> N6 -----> N9
在這樣我想遍歷節點並返回只是僅具有一個輸出關係(因此N5和N6中的例子)中的節點的結構。
我可以使用IteratorUtil類來獲取計數
Node process = db.getNodeById(2);
for(Relationship rel : process.getRelationships(Direction.OUTGOING))
{
Node appProcess = rel.getOtherNode(process);
if(IteratorUtil.count(appProcess.getRelationships(Direction.OUTGOING).iterator()) == 1)
{
System.out.println(appProcess.getId()+" is a vital process");
count++;
}
}
我願做相同的Cypher支架Java API的做到這一點。
它工作得像一個魅力;) – Ancelot182